Skip to content

docs(openapi): document billing verification errors#5493

Open
tagadearpit wants to merge 1 commit into
koala73:mainfrom
tagadearpit:agent/fix-5463-openapi-billing-contract
Open

docs(openapi): document billing verification errors#5493
tagadearpit wants to merge 1 commit into
koala73:mainfrom
tagadearpit:agent/fix-5463-openapi-billing-contract

Conversation

@tagadearpit

Copy link
Copy Markdown
Contributor

Summary

  • document retryable billing-verification 503 responses on authenticated operations
  • add Retry-After, X-Billing-Verification, and machine-readable error-code schemas
  • add the billing code enum to ForbiddenError for gated 403 responses
  • derive the contract from runtime entitlement and usage sources with fail-closed parsing
  • wire an idempotent injector and --check into OpenAPI generation

Fixes #5463

Validation

  • node --test --test-reporter=dot tests/openapi-billing-verification-contract.test.mjs
  • node --test --test-reporter=dot tests/openapi-rate-limit-errors-contract.test.mjs
  • Python YAML parse of all generated OpenAPI artifacts
  • DCO sign-off included

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@tagadearpit is attempting to deploy a commit to the World Monitor Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the trust:safe Brin: contributor trust score safe label Jul 23, 2026
@tagadearpit
tagadearpit marked this pull request as ready for review July 23, 2026 10:52
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Documents billing-verification failures in generated OpenAPI contracts.

  • Adds retryable billing-verification 503 responses, headers, and machine-readable error schemas to authenticated operations.
  • Extends forbidden-response schemas with billing error codes for gated 403 responses.
  • Adds a fail-closed, idempotent OpenAPI injector and wires it into generation and package scripts.
  • Adds contract tests covering generated billing-verification documentation.

Confidence Score: 4/5

The PR is safe to merge, with a non-blocking maintainability issue in the runtime-source parsing.

The generated billing contracts align with reachable authenticated behavior, but exact source-text sentinel checks make OpenAPI generation unnecessarily sensitive to behavior-preserving TypeScript refactors.

scripts/lib/openapi-codegen.mjs

Important Files Changed

Filename Overview
scripts/openapi-inject-billing-verification.mjs Adds deterministic JSON/YAML injection and freshness checking for billing-verification response contracts.
scripts/lib/openapi-codegen.mjs Adds fail-closed extraction of runtime contract metadata, with brittle exact-text sentinels for two billing values.
scripts/openapi-inject-security.mjs Extends the generated forbidden-error contract with billing-verification codes.
tests/openapi-billing-verification-contract.test.mjs Validates billing response schemas, headers, code enums, public-route exclusions, and artifact freshness.
Makefile Runs billing-contract injection after security injection during OpenAPI generation.
docs/api/worldmonitor.openapi.yaml Regenerates the bundled API contract with billing-verification responses and shared schemas.

Reviews (1): Last reviewed commit: "docs(openapi): document billing verifica..." | Re-trigger Greptile

Comment thread scripts/lib/openapi-codegen.mjs Outdated
Comment on lines +85 to +91
if (!entitlementSrc.includes("code: 'entitlement_verification_unavailable'")) {
throw new Error('could not locate entitlement_verification_unavailable in server/_shared/entitlement-check.ts');
}

const usageSrc = readFileSync(resolve(root, 'server/_shared/usage.ts'), 'utf8');
if (!usageSrc.includes("'billing_verification_503'")) {
throw new Error('billing_verification_503 usage reason is missing — refusing to run');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Avoid exact source-text sentinels

These checks depend on exact quoting and property text in runtime TypeScript, so a behavior-preserving refactor such as changing quote style or extracting the value blocks make generate. Parse the relevant declaration or export a shared machine-readable constant instead.

Knowledge Base Used: Proto/RPC contract system

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@rajpratham1 rajpratham1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request consistently documents billing verification and entitlement-related error responses across the OpenAPI specifications and supporting documentation. It updates the OpenAPI generation pipeline, regenerates the API specifications for all services, refreshes the generated documentation, and adds contract tests to validate the billing verification documentation. The visible changes are cohesive and appear to keep the generated artifacts, tooling, and tests in sync. No unresolved blocking issues are visible in the current diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trust:safe Brin: contributor trust score safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI specs: document billing-verification 503 + code on 403 for gated ops (post-#5447)

2 participants