Skip to content

fix: register discovery endpoint at /api/v1/discovery#621

Merged
hotlong merged 2 commits into
mainfrom
copilot/fix-discovery-api-endpoint
Feb 11, 2026
Merged

fix: register discovery endpoint at /api/v1/discovery#621
hotlong merged 2 commits into
mainfrom
copilot/fix-discovery-api-endpoint

Conversation

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

GET /api/v1/discovery returned 404 because no route was registered at that path. Discovery was only reachable at /api/v1 (RestServer) and /.well-known/objectstack (DispatcherPlugin), but Studio UI and user expectations reference /api/v1/discovery.

Changes

  • packages/rest/src/rest-server.tsregisterDiscoveryEndpoints() now registers the shared handler at both basePath and ${basePath}/discovery
  • packages/runtime/src/dispatcher-plugin.ts — Added GET ${prefix}/discovery route alongside /.well-known/objectstack
  • packages/rest/src/rest.test.ts — Updated route assertions for the new /discovery path

Discovery endpoints after this change

Path Provider
/.well-known/objectstack DispatcherPlugin
/api/v1 RestServer
/api/v1/discovery RestServer + DispatcherPlugin

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel

vercel Bot commented Feb 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Feb 11, 2026 1:32pm
spec Error Error Feb 11, 2026 1:32pm

Request Review

…/api/v1

Both RestServer and DispatcherPlugin now register discovery at the
/discovery sub-path so that GET /api/v1/discovery returns the API
discovery payload alongside the existing /api/v1 and
/.well-known/objectstack endpoints.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix discovery API endpoint access issue fix: register discovery endpoint at /api/v1/discovery Feb 11, 2026
Copilot AI requested a review from hotlong February 11, 2026 13:28
@hotlong
hotlong marked this pull request as ready for review February 11, 2026 13:33
Copilot AI review requested due to automatic review settings February 11, 2026 13:33
@hotlong
hotlong merged commit 8030ca6 into main Feb 11, 2026
6 of 7 checks passed

Copilot AI left a comment

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.

Pull request overview

Fixes a missing route registration so GET /api/v1/discovery no longer returns 404, aligning runtime behavior with Studio UI and expected discovery URL conventions.

Changes:

  • Register the RestServer discovery handler on both /api/v1 and /api/v1/discovery.
  • Add a /api/v1/discovery discovery route in DispatcherPlugin alongside /.well-known/objectstack.
  • Update REST route assertion tests to expect the new discovery path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/runtime/src/dispatcher-plugin.ts Adds GET ${prefix}/discovery route returning dispatcher discovery info.
packages/rest/src/rest-server.ts Reuses a shared discovery handler and registers it at both basePath and ${basePath}/discovery.
packages/rest/src/rest.test.ts Updates route assertions to include /api/v1/discovery and adjusts discovery-disable expectations.

Comment on lines +95 to +97
server.get(`${prefix}/discovery`, async (_req: any, res: any) => {
res.json({ data: dispatcher.getDiscoveryInfo(prefix) });
});

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

The newly added ${prefix}/discovery route in createDispatcherPlugin isn't covered by tests. Since packages/runtime already has Vitest coverage for runtime/dispatcher behavior, please add a unit test that starts the plugin against a mocked IHttpServer and asserts the discovery route is registered (and, ideally, that it doesn’t conflict when @objectstack/rest is also present).

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +97
server.get(`${prefix}/discovery`, async (_req: any, res: any) => {
res.json({ data: dispatcher.getDiscoveryInfo(prefix) });
});

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

createDispatcherPlugin now registers GET ${prefix}/discovery, but @objectstack/rest (RestServer) also registers GET /api/v1/discovery. In the default stacks (e.g. CLI serve and DevPlugin) both plugins are enabled, so this will double-register the same method/path on the same IHttpServer, which can cause route conflicts (some servers throw on duplicates, others have precedence rules) and can return a different payload shape than RestServer (Dispatcher returns HttpDispatcher.getDiscoveryInfo(...), RestServer returns protocol.getDiscovery()). Consider avoiding duplicate registration when com.objectstack.rest.api is present (e.g. via ctx.getKernel().getPlugins()), or make this handler delegate to the protocol discovery response to keep the payload consistent.

Copilot uses AI. Check for mistakes.
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.

3 participants