Repository navigation
feat(demo): reject unsupported capabilities with typed 503 - #1526
greatest0fallt1me merged 1 commit into
Conversation
|
@Gabriel-123-diamond Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Held: this large refactor (splitting |
Centralize demo configuration, return typed capability errors, prevent external database/client initialization, and expose the runtime health mode. Add route-table, configuration, lazy-pool and application regression tests. Closes CalloraOrg#1515
a2958f2 to
002a023
Compare
|
@greatest0fallt1me Rebased onto current main Validation: 56 focused tests pass with 100% guard coverage; both builds and Gitleaks pass. Full run: 2,776 passing / 17 failing tests; all failures are the four PostgreSQL Testcontainers suites, also failing on unchanged main because this Mac lacks a working container runtime. Lint startup and the same 254 typecheck diagnostic locations/codes are reproduced on unchanged main. The PR description includes the baseline comparison. GitHub now reports the PR as mergeable. One remaining contribution-specific CI blocker: openapi-compat rejects the issue-required addition of |
Closes #1515
Demo requests for PostgreSQL or Soroban capabilities return an immediate
503 DEMO_MODE_UNSUPPORTEDenvelope with the request ID anddetails.feature, withoutRetry-After. The seeded SQLite catalog remains available, and/api/healthreportsdata.mode(demoorstandard).DEMO_MODEis validated centrally. The billing client is never constructed in demo mode, including injected factories, and the lazy shared PostgreSQL pool rejects demo access before constructing a pool. Optional Horizon/RPC health probes are disabled in demo mode. No rawprocess.env.DEMO_MODEreads remain in application source.The exported
DEMO_UNSUPPORTED_ROUTEStable is the single source of truth. Tests verify each entry against the mounted Express route tree, with export configuration enabled for the conditional export routes./api/billing,/api/invoices/api/usage,/api/exports/api/admin/usage,/api/admin/db/explain/api/vault/deposit/prepare/api/vault/onchain,/api/vault/balance/api/audit/api/credits,/api/refunds/api/health/health,/api/health/dependenciesStandard-mode routing, authentication, exports and vault behavior are preserved. App wiring, configuration and envelope code use smaller modules to meet the contribution workspace's 250-line source-file limit; generated error codes retain their generator format.
Current-main integration
Rebased onto
5150bee72289229300d109fe7f52eceea19d7932, including #1550. The split modules preserve the restored database field names, testnet passphrase, StrKey validation, network/passphrase and secret/source-account consistency checks, production restrictions, and safe environment error reporting. They also retain the newer export configuration/storage validation, scheduled exports, idempotency lease/sweeper settings, settlement retry settings, and vault-reader wiring.The newer Soroban-backed vault reads are included in the demo guard so they cannot call RPC in demo mode; standard-mode controller behavior remains covered. A configuration comparison against current main confirms all 145 existing environment fields and 47 settings were carried across, with only the intended demo-mode additions/conditions.
Validation
Node 20.19.0 on x86_64 macOS, against current main above:
The full suite was run, with limitations reproduced on a separate unchanged checkout of current main using the same installed dependencies:
revenueLedgerIndexer, integrationidempotencySweeper,settlementStoreSchema, andquotaNotifier): no working container runtime is available on this Mac. The contribution run usesSQLITE_PATH=:memory:to isolate SQLite.restRateLimit.test.ts, which passes on the contribution.npm run lint: blocked on both by ESLint's missingajv/lib/refs/json-schema-draft-04.json.npm run typecheck: fails on both with the same 254 diagnostic locations/codes; no added diagnostic files/codes. Application compilation passes.Dependencies, lockfile, workflows and quarantine configuration are unchanged relative to current main. The full suite, lint and typecheck are not claimed as passing; remote CI must be assessed separately.
Original regression proof: billing/invoices and health integration checks failed before the demo implementation. Current coverage also verifies no pool connections/queries or billing factory calls in demo mode, method/path boundaries, seeded catalog access, standard health shape, production security checks in both modes, and no injected vault-reader calls for guarded demo requests.
Remote CI
At head
002a0233c31e2a15183d9c8af92d7e2fe01de3bd, openapi-compat fails because Optic treats adding the issue-requiredDEMO_MODE_UNSUPPORTEDmember to the shared responseErrorCodeenum as a breaking contract change. This is a contribution-specific compatibility-policy failure, distinct from the local baseline limitations above. The required enum addition and compatibility gate are retained for maintainer review; CI is not claimed green.