Skip to content

fix(phase6): demo-data fallback when Supabase env vars missing#96

Merged
vorionsys merged 3 commits intomainfrom
fix/phase6-stats-demo-fallback
Apr 11, 2026
Merged

fix(phase6): demo-data fallback when Supabase env vars missing#96
vorionsys merged 3 commits intomainfrom
fix/phase6-stats-demo-fallback

Conversation

@vorionsys
Copy link
Copy Markdown
Owner

Summary

Two related fixes for the Phase 6 Trust Engine Integration Test job.

1. apps/agentanchor/app/api/phase6/stats/route.ts
getPhase6Service() throws `Error('Missing Supabase configuration for Phase 6 service')` when `NEXT_PUBLIC_SUPABASE_URL` / `SUPABASE_SERVICE_ROLE_KEY` are unset (which they are in the integration-test and load-test CI jobs). That call was outside the inner try/catch that has the demo-data fallback, so the throw went straight to the outer catch and the route returned HTTP 500 `{"error": "Failed to fetch Phase 6 statistics"}`. Move the service instantiation inside the inner try so missing-config errors fall back to demo data — matching the stated intent of the fallback block.

2. packages/car-python/vorion_car/client.py
The HTTP error parser assumed every error body was shaped `{"error": {"message": "..."}}`, but our API returns `{"error": "..."}`. When the Python SDK hit the 500 above, it crashed with `AttributeError: 'str' object has no attribute 'get'` instead of raising a useful `CARError`. Handle both dict and string shapes.

Impact

  • Unblocks the Integration Test job in `ci-phase6.yml`.
  • The Load Test job (nightly-only, not blocking PRs) hits additional phase6 endpoints (role-gates, ceiling, provenance, alerts) that don't have demo fallbacks. That'll need a separate fix — either add demo fallbacks everywhere, restrict k6 smoke to `/stats` only, or supply real Supabase creds in CI.

Test plan

  • CI Integration Test job goes green
  • Existing tests in `apps/agentanchor/tests/api/phase6.test.ts` still pass
  • Python SDK unit tests still pass (if any exist for `_request` error handling)

@vorionsys vorionsys force-pushed the fix/phase6-stats-demo-fallback branch 7 times, most recently from 397106a to a1a3806 Compare April 11, 2026 22:46
chunkstar and others added 3 commits April 11, 2026 19:20
…error parser

Two related fixes for the Phase 6 Trust Engine integration test:

1. apps/agentanchor/app/api/phase6/stats/route.ts
   getPhase6Service() throws Error('Missing Supabase configuration for
   Phase 6 service') when NEXT_PUBLIC_SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY
   are unset (which they are in the integration-test and load-test CI jobs).
   That call was OUTSIDE the inner try/catch that handles the demo-data
   fallback, so the throw went straight to the outer catch and the route
   returned HTTP 500 {"error": "Failed to fetch Phase 6 statistics"}.
   Move the service instantiation inside the inner try so missing-config
   errors fall back to demo data, matching the stated intent of the
   fallback block.

2. packages/car-python/vorion_car/client.py
   The HTTP error parser assumed every error body was shaped
   {"error": {"message": "..."}}, but our API returns {"error": "..."}.
   When the Python SDK hit the 500 above, it crashed with
   AttributeError: 'str' object has no attribute 'get' instead of raising
   a useful CARError. Handle both dict and string shapes.

Unblocks the `Integration Test` job in ci-phase6.yml. The `Load Test` job
hits additional phase6 endpoints without demo fallbacks and will need a
separate fix (or scope restriction) — it's nightly-only so it doesn't
block PRs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Black (line-length=100, target-py39) reformatted client.py after the
previous commit. Zero semantic change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI runs 'black --check .' with no arguments, which uses Black's default
line-length of 88. My previous reformat used --line-length 100 to match
the ruff setting in pyproject.toml, which silently diverged from what
CI actually checks. Reformat with defaults.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vorionsys vorionsys force-pushed the fix/phase6-stats-demo-fallback branch from a1a3806 to dfa4408 Compare April 11, 2026 23:20
@vorionsys vorionsys merged commit 6200215 into main Apr 11, 2026
57 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants