Skip to content

aipm: trigger ai filter chain creation when parse_no_route - #49181

Open
botengyao wants to merge 4 commits into
envoyproxy:mainfrom
botengyao:ai-filter-chain-gating
Open

botengyao wants to merge 4 commits into
envoyproxy:mainfrom
botengyao:ai-filter-chain-gating

Conversation

@botengyao

@botengyao botengyao commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Commit Message: ai_protocol_manager: run AI filters on parse_unconfigured_routes requests
Additional Description: AI filters ran only on declared endpoints, so a route with no per-route config (e.g. a DFP catch-all) never reached schema validation's API detection. They now run on any parsed payload. Declared endpoints are unchanged; a best-effort body that fails to parse is still forwarded without running AI filters. With parse_unconfigured_routes on, AI filters may now reject requests on unconfigured routes, and bodies are re-serialized by default.

Risk Level: Medium (opt-in via parse_unconfigured_routes; alpha extension)
Testing: Unit and schema validation integration tests for unconfigured routes.
Docs Changes: AiProtocolManager.filters, RequestHandling.parse_unconfigured_routes, AI protocol manager filter docs.
Release Notes: Added to minor_behavior_changes.
AI usage: Written with Claude Code assistance; I reviewed and understand all of it.

…ests

The AI filter chain started only on declared endpoints, so a catch-all
route with no per-route config, such as a dynamic forward proxy's, never
reached schema validation to detect the API. Run the chain on any
request whose payload parsed; a best-effort payload that fails to parse
is still forwarded unchanged.

Signed-off-by: Boteng Yao <botengyao@gmail.com>
Signed-off-by: Boteng Yao <botengyao@gmail.com>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #49181 was opened by botengyao.

see: more, trace.

@botengyao
botengyao marked this pull request as ready for review November 11, 2026 17:58
@botengyao
botengyao requested a review from tyxia as a code owner November 11, 2026 17:58
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @wbpcode
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #49181 was ready_for_review by botengyao.

see: more, trace.

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.

🟡 Changes recommended

Parsing unconfigured routes can incorrectly enable response filtering without an AI chain, rewriting responses that should pass through and potentially triggering response errors.

1 open issue
What changed in this PR

This PR extends Envoy’s AI protocol manager to run AI filters on successfully parsed requests from unconfigured routes, enabling schema validation to detect APIs on catch-all routes.

Changes:

  • Trigger AI filters after successful parsing, while preserving passthrough for unparseable best-effort payloads.
  • Add unit and integration coverage for unconfigured-route filtering, API detection, and rejection.
  • Update API comments, user documentation, and release notes.
File Description
test/​extensions/​http/​ai_filters/​schema_validation/​schema_validation_integration_test.cc Tests API detection and rejection on unconfigured routes.
test/​extensions/​filters/​http/​ai_protocol_manager/​filter_test.cc Tests filter execution and unparseable-payload passthrough.
source/​extensions/​filters/​http/​ai_protocol_manager/​filter.h Tracks successful request parsing and updates behavior comments.
source/​extensions/​filters/​http/​ai_protocol_manager/​filter.cc Starts AI filtering based on successful parsing.
docs/​root/​configuration/​http/​http_filters/​ai_protocol_manager_filter.rst Documents filtering on unconfigured routes.
changelogs/​current/​minor_behavior_changes/​ai_protocol_manager__ai-filters-on-unconfigured-routes.rst Announces the opt-in behavior change.
api/​envoy/​extensions/​filters/​http/​ai_protocol_manager/​v3/​ai_protocol_manager.proto Clarifies filter execution and possible rejection in API comments.

Review effort: Balanced

@@ -514,7 +515,7 @@ void AiProtocolManagerFilter::finalizeDecode(bool has_trailers) {
}
};

if (isAiEndpoint() && !decode_manager_->empty() && !payload_rejected_) {
if (request_parsed_ && !payload_rejected_) {
Signed-off-by: Boteng Yao <botengyao@gmail.com>
Signed-off-by: Boteng Yao <botengyao@gmail.com>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants