Repository navigation
fix(ingestion): resolve tenant_validation import in prod image - #3793
PetrefiedThunder wants to merge 6 commits into
Conversation
Absolute ``from app.tenant_validation`` inside webhook_compat.ingest_events resolved to another service's ``app`` package under the consolidated server/PYTHONPATH layout, so CSV and EDI ingest returned 500 in production. Use a package-relative import instead. Origin: uncommitted patch from C.Lee's interactive Claude session on Mac 33e1b4b0 (webhook_compat.py +14/-4); kept only the import-path fix and dropped the unrelated canonical dual-write edits. Adds a regression test that reproduces the prod path bootstrap and exercises the recorded shipping CSV and 856 EDI fixtures.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Blocker ChecklistHead SHA: Status: Ready
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
REVIEW: PASS hermes c38f065 Same head SHA I passed on #3774 (#3774 (comment)), re-opened unchanged on claude/ingest-import-path. Same two files: services/ingestion/app/webhook_compat.py and services/ingestion/tests/test_prod_import_path_tenant_validation.py. Prior findings stand: the relative import is correct; 3 new tests and 99 related tests passed. Non-blocking caveat from before: the test's sys.path order doesn't match the Dockerfile's PYTHONPATH order. |
detect-secrets Secret Keyword flagged x_regengine_api_key="test-key" in the new prod-path regression test (PR Gate: Secrets). Mark the fixture strings with pragma allowlist; not a real credential. Signed-off-by: C.Lee Sellers <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
REVIEW: PASS deepseek 6d6c8ea Engine: DeepSeek ( Author check: Local: the 3 tests in DeepSeek findings (all non-blocking, test hygiene):
Nothing pushed. |
Require both CSV and EDI HTTP routes to reach ingest_events (assert csv_upload and edi_856_inbound in seen); POST EDI at /api/v1/ingest/edi. Restore sys.path via monkeypatch and reinstall purged app modules at fixture teardown; patch validate_tenant_id with monkeypatch.setattr. Signed-off-by: C.Lee Sellers <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
…h harden Bring in 6d6c8ea (merge main into claude/ingest-import-path) under the local test hygiene commit so the tip can plain-push. Signed-off-by: C.Lee Sellers <131207452+PetrefiedThunder@users.noreply.github.com> Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
PetrefiedThunder
left a comment
There was a problem hiding this comment.
REVIEW: PASS deepseek b2a8773
Engine: DeepSeek, delta re-review from prior PASS 6d6c8ea9 (issuecomment-6599006457) → exact head b2a87737ccaf842c0dd6ad8ae04e2ed825b78d95, Nov 3, 2026 ~1:24 AM PT. Worktree /workspace/RegEngine-ingest-import-path.
Delta (2 commits):
1e53edetest(ingestion): harden prod-path CSV/EDI ingest regressionb2a87737merge of that harden onto prior6d6c8ea9tip
Merge identity: HEAD is a 2-parent merge (1e53ede + 6d6c8ea9). git merge-tree --write-tree equals HEAD^{tree} (4422c265…). Only file touched vs prior PASS: services/ingestion/tests/test_prod_import_path_tenant_validation.py (+29/−17).
Prior nits / CodeRabbit majors — verified fixed:
sys.pathnow set viamonkeypatch.setattr(sys, "path", …)in_bootstrap_prod_sys_path.- Purged
app/app.*modules saved and restored in fixturefinally. validate_tenant_idpatched withmonkeypatch.setattr(tv_mod, …)(no bare global assign).- Route coverage tightened: both CSV and EDI HTTP paths must reach
ingest_events(csv_upload/edi_856_inboundinseen); EDI posts to/api/v1/ingest/edi.
Synthetic key / allowlist (unchanged, still scoped to fixture):
x_regengine_api_key="test-key"with# pragma: allowlist secret — synthetic test fixture onlyon the fixture call sites only.- Author of allowlist commit
ed48d785remains PetrefiedThunder (not deepseek).
Local: pytest services/ingestion/tests/test_prod_import_path_tenant_validation.py → 3 passed.
CI on this exact head: green except ignored gate-only checks (Engine Review Pass / Head SHA / PR Blocker Checklist). Notably: Ingestion full suite, Test ingestion, Repo-root security/RLS/isolation, Live DB, Tenant Isolation & Auth, PR Gate: Backend, Backend CI Status Gate, PR Gate: Secrets — SUCCESS.
Nothing pushed.
Supersedes #3774 (same commit
c38f065c8ac19f12ee4e390a5437d958fa6b9c2bon an engine-prefix branch so Engine Review Pass accepts the author). Hermes PASS on #3774: #3774 (comment)Summary
Production CSV and EDI ingest returned 500 because
services/ingestion/app/webhook_compat.pyused an absolutefrom app.tenant_validationimport. Under the consolidated server / DockerPYTHONPATHlayout, top-levelappresolves to another service's package (compliance/graph/...), not ingestion.Fix
from .tenant_validation import validate_tenant_id.33e1b4b0(webhook_compat.py+14/-4). Kept only the import-path fix; dropped the unrelated canonical dual-write edits in that working-tree diff.from app.tenant_validationcall sites in ingestion app code. Leftlabels/gs1_128.py's unrelatedfrom app.gs1_identifiersalone (not the CSV/EDI 500 path; not payment/security/receipt).Test plan
server/main.pypath bootstrap, asserts absolute import fails, and runs recorded fixturesshipping_pass_partner.csvandedi_corpus/asn_856.edithroughingest_events(and CSV/EDI HTTP routes) without a 500.pytest services/ingestion/tests/test_prod_import_path_tenant_validation.py— 3 passedPYTHONPATH/ path order instead.Hermes review requested.
Mac working tree left untouched (diff copied out only; no commit/stash/reset on the Mac).
Note
Low Risk
Single import-path change on the ingest hot path; behavior is unchanged when the correct module loads, and regression tests cover the prod layout.
Overview
Fixes production 500s on CSV and EDI ingest caused by
ingest_eventsimporting tenant validation via top-levelfrom app.tenant_validation, which resolves to another service’sapppackage in the consolidated server/DockerPYTHONPATHlayout.webhook_compat.pynow usesfrom .tenant_validation import validate_tenant_idso validation always loads ingestion’s module, with a short comment explaining the collision.Adds
test_prod_import_path_tenant_validation.py, which mirrorsserver/main.pypath ordering, confirms the old absolute import fails, and runs recorded CSV/EDI fixtures throughingest_eventsand the CSV/EDI HTTP routes without a 500.Reviewed by Cursor Bugbot for commit b2a8773. Bugbot is set up for automated code reviews on this repo. Configure here.