fix(cli): 'enrich-agencies --only ep --portal' skips cleanly, no KeyError (#152) - #200
Merged
Conversation
…rror (#152) EP procures via Bonfire, not a bids&tenders portal (#134), so it has no entry in the body-name -> portal-slug map. `--only` accepts "ep" (a real body), so `{"trca": "trca", "zoo": "toronto-zoo"}[args.only]` raised an uncaught KeyError for that combination -- caught by the surrounding try/except and recorded as a portal FAILURE for a body that was never supposed to have one. `.get(args.only)` plus an explicit clean-skip branch when it returns None for a named body. `--only trca --portal` / `--only zoo --portal` and the no-`--only` fan-out are unchanged -- the slug mapping (the reason the lookup existed) is preserved verbatim. Verified live against the exact command from the issue: ep EP agendas : 0 (cached) ep stored : 0 solicitations, 0 awards (+0), 0 bids (+0) portal listings : ep has no bids&tenders portal — skipping suppliers : 0 exit=0 5 new tests. Confirmed red against the pre-fix code (the EP test fails with the exact `FAILED portal: 'ep'` this issue reports; the other 9 stay green), then restored. 774 tests passing. 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 #152.
The bug
tb enrich-agencies --only ep --portalraisedKeyError('ep'):EP procures via Bonfire, not a bids&tenders portal (#134), so it has no entry in the
body-name → portal-slug map.
--onlyacceptsepas a real body, so the combination isreachable — and the KeyError was caught by the surrounding
try/exceptand recorded as aportal FAILURE for a body that was never supposed to have one, which is what made the
symptom misleading rather than just a crash.
The fix
.get(args.only)plus an explicit clean-skip branch when it returnsNonefor a named body:--only trca --portal/--only zoo --portaland the no---onlyfan-out are unchanged — theslug mapping (the reason the lookup existed: the body name and the portal's own slug differ for
the zoo) is preserved verbatim.
Verification
Live, against the exact command from the issue:
5 new tests, confirmed genuinely red against the pre-fix code by reverting the fix in place:
the EP test fails with the exact
FAILED portal: 'ep'this issue reports, while the other 9existing/new tests in the file stay green — proving the fix is targeted, not incidentally masking
something else. Restored after.
774 tests passing.
🤖 Generated with Claude Code
https://claude.ai/code/session_01W53WHx8mm2UHuLFAQWeF62