Skip to content

Report unsendable OpenAPI operations during import - #2595

Open
yashgix wants to merge 1 commit into
UsefulSoftwareCo:v2from
yashgix:import-diagnostics
Open

yashgix wants to merge 1 commit into
UsefulSoftwareCo:v2from
yashgix:import-diagnostics

Conversation

@yashgix

@yashgix yashgix commented Nov 24, 2026 •

Copy link
Copy Markdown

Problem

Some OpenAPI operations compile into tools that can never make a valid request. A path that names {report_slug} while the operation declares report_id, a template like /users/{id?}, or a GET that requires a body all end the same way: the tool is offered, an agent calls it, and every call fails with an error the agent cannot fix. The agent spends turns on a tool that was never usable.

Change

Import now checks each operation for these cases. It leaves the operation out of the tool list and records the reason with the other skipped operations:

  • a path placeholder with no declared path parameter
  • a declared path parameter the path writes as :name or *name, or beside a regex group such as (\d+), which OpenAPI never fills
  • a stray brace in a path template, such as /users/{id?}
  • a required body on GET or HEAD, which fetch cannot send

Operations that stay callable

The check refuses only what cannot work. Tools that send a correct request today keep working, and the tool description says what was left out:

  • An optional GET or HEAD body is left out of the tool input.
  • A declared path parameter the path does not hold stays callable. Its description says "Its path does not hold extra, so any value given is not sent." The tool still asks for the value, so callers keep the same input.
  • A placeholder after ? counts as held, because the request builder fills it (/search?limit={limit} sends ?limit=5). One after # does not, because the fragment is dropped.
  • Literal colons and parentheses are kept: /files/{id}:copy, /items(archived)/{id}.

Behaviour changes

  • Operations in the first list are no longer exposed as tools.
  • GET and HEAD tools lose an optional body from their input.
  • Tools with a declared path parameter the path does not hold gain one sentence in their description.

Verification

Results for this change alone, on the final commit:

  • bun run e2e:self-host --test-name "OpenAPI import reports a misnamed path parameter, a :name placeholder and a required GET body, drops an optional body, and keeps an operation with a path parameter its path does not hold" passes. It covers each case above, a call to a kept tool with an extra path parameter that reaches /items/7, and a /search?limit=5 call. With real v2 product code and only this scenario added, it fails at the first operation the check refuses.
  • The format check and oxlint are clean on the changed files. tsc passes for the root and e2e projects. bun run typecheck (9 projects) and bun run e2e:check pass.

Import-level results on public specs, offline. They were observed in the combined benchmark (this change and #2590 applied together) and were not measured for this change alone. Which operations import exposes does not depend on #2590, so they describe this change's import behaviour:

  • In two samples (134 apps, 22,954 operations, 68,090 generated inputs), no operation that matched the spec before is refused, and 157 operations that failed on every call are now named at import.
  • In 9 stored specs, import refuses at most 33 operations that v2 exposes: 22 whose path has a placeholder no declared parameter fills, and 11 written as :name or *name. This was counted before a final narrowing of the regex-group rule, which can only lower it.
  • With both changes applied, a regression gate over 18 apps and 4,792 operations reports nothing worse.

The query-encoding results are in #2590 and are not part of this change.

Scope and limits

  • An undeclared placeholder after ? (/find?limit={limit} with no limit declared) is not diagnosed. It is sent as limit=%7Blimit%7D. A query may also hold literal braces, so diagnosing it needs a rule for which braces count.
  • Template patterns the check does not recognize are kept: /jobs/:jobId.json declaring jobId, and /jobs/:id declaring jobId. Both send the colon segment as written. A wildcard written {resource_path*} or {*path} has a different name from the declared parameter, so it is refused as an undeclared placeholder.
  • A declared path parameter the path does not hold stays required in the tool input.
  • Checks run here: the scenario once, in a container. pr:check cannot run as a whole because v2 and main share no history. The release-note check and e2e:check-description ran on an earlier revision of this change that edits the same four files, and were not rerun on the final commit. apps-version was not run. No live provider was called.
openapi-import-diagnostics.spec.ts

I directed the scope and review of this contribution, using Claude Code during implementation and additional AI tools for independent review. The tests, measurements, and known limitations are documented above.

An operation is left out with its reason when its path has a placeholder with no declared path parameter, writes a declared parameter as :name, *name or beside a regex group such as (\d+), has a stray brace such as /users/{id?}, or is a GET or HEAD that requires a body. An optional GET or HEAD body, and a declared path parameter the path does not hold, are not sent and are named in the tool description, so the tool stays callable.

Release-note: Fix: OpenAPI imports now explain which operations cannot be called and why, instead of offering tools that always fail.

This branch has not been deployed

No deployments
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.

1 participant