Skip to content

fix(runtime): serve /discovery with Cache-Control: no-store (cloud#152)#1963

Merged
os-zhuang merged 1 commit into
mainfrom
fix/discovery-no-store
Jun 16, 2026
Merged

fix(runtime): serve /discovery with Cache-Control: no-store (cloud#152)#1963
os-zhuang merged 1 commit into
mainfrom
fix/discovery-no-store

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Bug (cloud#152)

Discovery reflects mutable runtime config — routes.mcp is only advertised when OS_MCP_SERVER_ENABLED=true. But the discovery routes set no Cache-Control, so an edge/CDN can cache the response. On a staging env, after enabling MCP, GET /api/v1/discovery kept returning routes.mcp: undefined (stale, even with cache-busting query params) while POST /api/v1/mcp correctly served — so the objectui Integrations page showed "MCP not enabled" against a live server.

Root cause

getDiscoveryInfo() (http-dispatcher.ts) and isMcpEnabled() (reads process.env fresh) recompute the payload correctly per request — the in-app value is never stale. buildSecurityHeaders() sets no Cache-Control (its max-age is HSTS). So the only staleness is the HTTP cache layer.

Fix

Mark both discovery routes (/.well-known/objectstack + ${prefix}/discovery) Cache-Control: no-store. res.header() is the same emit method the adjacent no-cache routes use. +regression test asserting the header on both routes.

Test

@objectstack/runtime builds clean; dispatcher-plugin.routes.test.ts green (4/4, incl. the new no-store assertion).

Note: the actual CF-edge cache only clears once cloud bumps .framework-sha to this and deploys to staging.

🤖 Generated with Claude Code

The discovery payload reflects MUTABLE runtime config — notably `routes.mcp`,
which is only advertised when OS_MCP_SERVER_ENABLED=true. getDiscoveryInfo()
(and isMcpEnabled(), which reads process.env fresh) recompute it correctly on
every request, but the two discovery routes (`/.well-known/objectstack` and
`${prefix}/discovery`) emitted no Cache-Control header, so an edge/CDN could
cache the response. After MCP was enabled on a staging env, GET /discovery kept
returning `routes.mcp: undefined` (stale, even with cache-busting query params),
so the objectui Integrations page rendered "MCP not enabled" against a live MCP
server.

Mark both discovery routes `Cache-Control: no-store` so the payload is never
cached — config changes (enable MCP, add a plugin/service) are reflected
immediately. +regression test asserting the header on both routes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 16, 2026 10:38am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/runtime)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/concepts/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/api-reference.mdx (via @objectstack/runtime)
  • content/docs/guides/authentication.mdx (via @objectstack/runtime)
  • content/docs/guides/cloud-deployment.mdx (via @objectstack/runtime)
  • content/docs/guides/deployment-vercel.mdx (via @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/runtime)
  • content/docs/guides/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/guides/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/plugin-chatbot-integration.mdx (via @objectstack/runtime)
  • content/docs/guides/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/guides/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit 054d144 into main Jun 16, 2026
14 checks passed
@os-zhuang
os-zhuang deleted the fix/discovery-no-store branch June 16, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant