fix(ariba): a placeholder credential reads as unset, not truthy (#184) - #193
Merged
Merged
Conversation
`scrapers/.env.example` ships in git with placeholder values so the repo
can stay public. On a checkout that copied it to `scrapers/.env` but never
filled it in, `load_dotenv()` puts those placeholders into the real
environment, and `os.environ.get(...)` reads them back as non-empty
strings. `capture_attachments`'s own "creds unset" guard checks truthiness,
which a placeholder satisfies — so the guard never fired, `login()`
proceeded, and the run died 30s later inside Playwright
(`fill("your-ariba-supplier-username")` timing out) with nothing saying
why. This exact scenario cost real time during the #174 session.
`config._real_env` treats a value equal to the known placeholder as None at
load time — the one place both the existing guard and any future caller
check. Verified against this actual checkout, which still has a leftover
placeholder `scrapers/.env` from an earlier session:
ARIBA_USERNAME: None (was 'your-ariba-supplier-username')
ARIBA_PASSWORD: None (was 'your-ariba-supplier-password')
and confirmed `capture_attachments` now raises immediately (no Playwright
launch) instead of hanging for 30s.
Deliberately not addressed: the issue's "also worth considering" note about
`#userid` resolving to 2 elements on Ariba's login page. That's a live
browser-automation detail I have no way to re-verify against the real
Ariba login page in this session, and the issue itself frames it as
something to watch for, not a required fix.
847 tests passing (840 + 7 new).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W53WHx8mm2UHuLFAQWeF62
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #184.
The bug
scrapers/.env.exampleships in git with placeholder values so the repo can stay public:On a checkout that copied it to
scrapers/.envbut never filled in real credentials,load_dotenv()puts those placeholders into the real environment, andos.environ.get(...)reads them back as non-empty strings.
capture_attachments's own "creds unset" guard checkstruthiness (
if not (config.ARIBA_USERNAME and config.ARIBA_PASSWORD)), which a placeholdersatisfies — so the guard never fired.
login()proceeded and the run died 30 seconds laterinside Playwright:
The value is right there in the log, but nothing says "you have no credentials configured." This
cost real time during the #174 session before the cause was spotted.
The fix
config._real_env(name)treats a value equal to the known placeholder asNoneat load time —the one place both the existing guard and any future caller check:
No changes needed to
ariba_attachments.pyat all — the existing "unset" guard and its message("Put them in scrapers/.env") already say exactly the right thing once the value is
None.Verification
Against this actual checkout, which still has a leftover placeholder
scrapers/.envfrom anearlier session:
And confirmed
capture_attachmentsnow raises in well under a second — no Playwright launch atall — instead of hanging for 30s:
847 tests passing (840 + 7 new):
test_config.pycovers_real_envin isolation (placeholder→ None, real credential passes through, genuinely-unset stays None, and that one variable's
placeholder can't accidentally blank the other), plus two tests in
test_ariba_attachments.pyconfirming
capture_attachmentsfails fast for both a genuinely-missing and a placeholdercredential.
Deliberately not addressed
The issue's "also worth considering" note:
login()fills#userid, which Playwright reportsresolving to 2 elements on Ariba's real login page (works today via the legacy non-strict
fill()API, but is "the kind of thing that silently changes"). That's a live browser-automation detail I
have no way to re-verify against Ariba's actual login page in this session, and the issue frames
it as a watch-item, not a required fix — left alone rather than changing selector behavior I can't
test.
🤖 Generated with Claude Code
https://claude.ai/code/session_01W53WHx8mm2UHuLFAQWeF62