Skip to content

fix(proxy): return 404 for unknown paths on OpenAI ingress - #3197

Merged
i386 merged 1 commit into
mainfrom
kleinbem/ingress-unknown-path-404
Nov 29, 2026
Merged

i386 merged 1 commit into
mainfrom
kleinbem/ingress-unknown-path-404

Conversation

@kleinbem

@kleinbem kleinbem commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Title

fix(proxy): return 404 for unknown paths on OpenAI ingress

Original problem

Fixes #3186. Sending a JSON POST to an unknown path on the OpenAI ingress port (such as /api/plugins/... sent to :9337 instead of console :3131) enters automatic model routing, picks a random plugin model, and fails with a confusing 503 (plugin endpoint for model '...' failed) instead of 404. Model-less unknown GET requests hit the first_available_target fallback (503 when no native targets exist, or forwarding an unknown path to a native backend).

Callers hitting the wrong port or a typoed path get misleading 503 backend failures and trigger unnecessary routing work instead of a clear 404 not_found.

Diagnostics

On main, both POST /api/plugins/mesh-dev/tools/env_probe (with body {}) and GET /does-not-exist on OpenAI ingress fail the new regression tests with HTTP/1.1 503 Service Unavailable instead of 404.

Fix

  • Add workload_routing::is_openai_ingress_backend_path(method, path) covering the known OpenAI ingress backend routes (workload-classified inference routes, System One routes, /v1/messages/count_tokens, /v1/tokenize, and GET/HEAD /health//healthz//readyz).
  • Add send_route_not_found_observed in response/send.rs returning 404 with "code": "not_found" (matching InferenceError::route_not_found).
  • Enforce the route check after control-plane routing (maybe_handle_control_request / handle_mesh_control_request) in both ingress/buffered_exchange.rs and transport.rs (bootstrap proxy).
  • Add regression tests in ingress_tests/unknown_path.rs.

Validation

  • I ran the regression tests against main (confirmed 503 failure) and verified cargo fmt, cargo clippy, CI contracts, and mesh-llm-host-runtime tests (Linux, Windows) pass with the fix.
  • No UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • Requests to unrecognized OpenAI ingress paths now receive a consistent 404 not_found response instead of being forwarded to backend services or plugin inference endpoints.
    • Recognized API, health, and readiness routes continue to be handled as before, including requests with query parameters.
    • Unknown paths handled through the bootstrap mesh handler also return a 404 response.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 039de524-22f0-4aca-9bab-4c41080894d8
Commits

Reviewing files that changed from the base of the PR and between 4fbf593 and 94b2222.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The OpenAI ingress now checks whether requests match supported backend paths. Non-matching requests receive an observed 404 and are not forwarded. Tests cover admitted routes, rejected routes, and plugin non-forwarding.

Changes: OpenAI ingress route handling

Layer / File(s) Summary
Backend-path predicate and 404 response
mesh/crates/mesh-llm-host-runtime/src/network/openai/workload_routing.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/response.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/response/send.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/transport.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/response/external_endpoint.rs
is_openai_ingress_backend_path matches workload-class and System One routes, token utility routes, and selected health routes. The response helper sends an observed 404 with code not_found and no retry delay. The external-endpoint route test checks that accepted paths also match ingress admission or model discovery.
Ingress rejection and validation
mesh/crates/mesh-llm-host-runtime/src/network/openai/transport.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/ingress/buffered_exchange.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/ingress.rs, mesh/crates/mesh-llm-host-runtime/src/network/openai/ingress_tests/unknown_path.rs
Both ingress handlers return an observed 404 for non-matching routes and release request objects. Tests check route admission, 404 responses, bootstrap mesh handling, and that an unknown POST does not connect to the configured plugin endpoint.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Ingress as OpenAI ingress handler
  participant PathCheck as is_openai_ingress_backend_path
  participant NotFound as send_route_not_found_observed
  Client->>Ingress: Send request
  Ingress->>PathCheck: Check method and path
  PathCheck-->>Ingress: Return non-matching result
  Ingress->>NotFound: Send observed 404
  Ingress-->>Client: Return not_found response
Loading
Merge Risk: Minimal · previous review 4fbf5

Unknown paths on the OpenAI ingress now return 404 with code not_found instead of being routed to a model and failing with a misleading 503. No concrete merge-blocking risk was found. Model discovery and the supported inference routes still pass through the existing handlers before the new check.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(proxy): return 404 for unknown paths on OpenAI ingress" states the main change. The raw summary and objectives show the PR returns observed 404 responses with code not_found for unknown…
Linked Issues check Passed Issue #3186 requires an unknown path on the OpenAI ingress port to return 404 without model selection or forwarding to a backend. The example case is a JSON POST with body {} to /api/plugins/.../tools…
Out of Scope Changes check Passed All changes connect to issue #3186. The new predicate defines which paths the ingress forwards. The 404 sender, its re-export in response.rs and transport.rs, the gates in buffered_exchange.rs and tra…
Full details: Title check

Explanation

The title "fix(proxy): return 404 for unknown paths on OpenAI ingress" states the main change. The raw summary and objectives show the PR returns observed 404 responses with code not_found for unknown paths on the OpenAI ingress, instead of routing them to a model and returning 503. The title is specific, concise, and free of file lists or vague terms. Its scope matches the changeset.

Full details: Linked Issues check

Explanation

Issue #3186 requires an unknown path on the OpenAI ingress port to return 404 without model selection or forwarding to a backend. The example case is a JSON POST with body {} to /api/plugins/.../tools/... that currently reaches automatic routing and returns 503. The PR adds workload_routing::is_openai_ingress_backend_path, which gates unknown paths. In ingress/buffered_exchange.rs, the gate runs after control-plane handling and before callable_models() and automatic routing. On failure, the handler sends send_route_not_found_observed (404, code not_found) and returns. In transport.rs, handle_mesh_control_request applies the same gate after control-plane handling. I read this hunk directly at the reviewed head. It sends the 404, terminalizes the lifecycle, releases request objects, and returns None. The unknown_path regression tests cover the POST /api/... case and unknown GET paths, per the summary. I did not re-run the tests. The buffered_exchange.rs hunk is taken from the summary and was not read directly. Coverage of issue #3186 is established.

Full details: Out of Scope Changes check

Explanation

All changes connect to issue #3186. The new predicate defines which paths the ingress forwards. The 404 sender, its re-export in response.rs and transport.rs, the gates in buffered_exchange.rs and transport.rs, the unknown_path tests, and the external_endpoint.rs documentation and path-admission test all implement or document the 404 behavior. The external_endpoint.rs change keeps the external-forwarding path list aligned with ingress admission. No unrelated functional change appears in the summary or the transport.rs hunk. Residual compatibility risk remains: any ingress-forwarded path absent from the predicate now returns 404 instead of forwarding. The predicate covers request_workload_class routes, System One routes, /v1/messages/count_tokens, /v1/tokenize, and GET/HEAD health routes. I did not enumerate every path the ingress forwards, so this is a compatibility concern to verify, not a demonstrated out-of-scope change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87862447-9cc2-44df-b828-5ffecef39966
Commits

Reviewing files that changed from the base of the PR and between 3087dde and 4fbf593.

Files selected for processing: 3

  • mesh/crates/mesh-llm-host-runtime/src/network/openai/ingress_tests/unknown_path.rs
  • mesh/crates/mesh-llm-host-runtime/src/network/openai/response/external_endpoint.rs
  • mesh/crates/mesh-llm-host-runtime/src/network/openai/workload_routing.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

kleinbem added a commit to kleinbem/mesh-dev-plugin that referenced this pull request Nov 22, 2026
Pin the three upstream Mesh-LLM PRs uncovered with `mesh-dev` in
`docs/CAPABILITY_AUDIT.md` and
`suites/01-core-inference-and-inspector.toml`:
- `upstream: Mesh-LLM/mesh-llm#3194` (pre-header client disconnect
cancellation)
- `upstream: Mesh-LLM/mesh-llm#3196` (plain-HTTP plugin health probe
without system CA certs / loopback proxy bypass)
- `upstream: Mesh-LLM/mesh-llm#3197` (OpenAI ingress 404 for unknown
paths, paired with `tracking: Mesh-LLM/mesh-llm#3186`)

@ndizazzo ndizazzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The 404 gate covers both the local and mesh-forwarded paths and the tests check that nothing reaches the plugin endpoint. One P3 note inline.

/// Whether `method` + `path` is a known backend route forwarded by the OpenAI
/// ingress listener (after control-plane routes like `/v1/models` and legacy
/// lifecycle checks have already run).
pub(super) fn is_openai_ingress_backend_path(method: &str, path: &str) -> bool {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P3] This allowlist now lives next to is_forwardable_external_endpoint_path in external_endpoint.rs, which has a slightly different route set. A new ingress route that only lands in one of them will 404 here, or be refused at the backend, with no test tying the two together. Optional: add a short comment on both pointing at each other, or build the external list from this one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Rebased and added cross-ref comments on both allowlists, and tied them together in the external endpoint test so any forwardable route has to be admitted at ingress too. Also added a 404 test for the bootstrap proxy path.

@kleinbem
kleinbem force-pushed the kleinbem/ingress-unknown-path-404 branch from 4fbf593 to 94b2222 Compare November 28, 2026 23:56
@i386
i386 merged commit 107e1e0 into main Nov 29, 2026
15 checks passed
@i386
i386 deleted the kleinbem/ingress-unknown-path-404 branch November 29, 2026 03:07
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.

OpenAI ingress port auto-routes unknown /api/... POSTs to a plugin model instead of returning 404

3 participants