Fix Planner login: password field submitted empty since 2026-07-31

Microsoft changed the converged sign-in page to pre-render the password
view, so input#i0118 is present and visible while the email view is still
on screen. wait_for_selector() for the password field therefore returned
immediately, the fill landed mid view-switch and was wiped, and the Sign in
click submitted an empty box ("Please enter your password."). Planner never
loaded, no Graph request fired, and the run died with "Could not capture
Bearer token" on every machine from 2026-07-31 onwards.

Login flow:
- _fill_verified(): wait for the field to be interactive, fill, and read the
  value back before submitting; retry when it does not stick.
- _submit_password()/_submit_totp(): confirm the page actually advanced, and
  raise a specific error naming Microsoft's message when a credential is
  rejected instead of timing out silently.
- _skip_login_interrupt(): dismiss the post-sign-in interstitials, including
  "Let's keep your account secure", which was also never handled. The old
  "Stay signed in?" handler only matched input#idBtn_Back and Microsoft now
  renders that control as a <button>.

Token capture:
- Listen at context level so popups are observed.
- _TokenStore falls back to any graph.microsoft.com Bearer if no Planner-scoped
  call appears, and records every Graph URL seen for diagnosis.
- MSAL localStorage fallback when no Graph request is intercepted at all.
- On failure, dump a screenshot, the page HTML and the request summary next to
  the run log so the next regression does not need a code change to diagnose.
- Login timeout 120s -> 180s, with one retry of the whole login.

Also: force UTF-8 on stdout/stderr (the error banner crashed with
UnicodeEncodeError on a cp1252 console, hiding the real error), and only
prompt "Press Enter to close" when stdin is a TTY so scheduled runs do not
fail with EOFError.

Build: onedrive_planner_http.spec was gitignored and missing from the repo, so
build_exe.bat could not run; it is now tracked. requirements.txt was missing
httpx, playwright and python-dotenv.

Verified: scripts/verify_login.py completes login, token capture and read-only
Graph access (63 plans discovered). 103 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
VasanthandClaude Opus 5 committed 2026-08-03 12:46:59 +05:30
1 parent 291507c2f7
commit dd864e0b4c
7 files changed
+969 -73

No files matched your search

+83
View File
@@ -0,0 +1,83 @@
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller spec for MISF_Planner_Download.exe (onedir build).
Layout produced (matches what is deployed to D:\\MISF_Planner_Download):
MISF_Planner_Download.exe
_internal/
src/*.py <- imported via sys.path at runtime
playwright/driver/... <- node.exe + cli.js, used to auto-install Chromium
<bundled dependencies>
"""
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
block_cipher = None
# src/ is shipped as data, not as a package: onedrive_planner_http.py puts it on
# sys.path at import time (ROOT / "src"), and PROJECT_ROOT resolves next to the
# .exe so Input/ and Output/ stay outside the bundle.
datas = [("src", "src")]
# node.exe + package/cli.js — _ensure_playwright_browsers() shells out to these
# on a machine that has no Chromium yet.
datas += collect_data_files("playwright")
hiddenimports = [
"checkpoint",
"config",
"logging_setup",
"onedrive_planner",
"run_log",
"totp_utils",
"pyotp",
"openpyxl",
"openpyxl.cell._writer",
]
hiddenimports += collect_submodules("playwright")
a = Analysis(
["onedrive_planner_http.py"],
pathex=["src"],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=["tkinter", "matplotlib", "PyQt5", "PySide2", "IPython"],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="MISF_Planner_Download",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="MISF_Planner_Download",
)