Skip to content

Report AI models requested via OpenRouter and Vercel API's#458

Open
reiniercriel wants to merge 4 commits into
mainfrom
feat/ai-aggregators
Open

Report AI models requested via OpenRouter and Vercel API's#458
reiniercriel wants to merge 4 commits into
mainfrom
feat/ai-aggregators

Conversation

@reiniercriel
Copy link
Copy Markdown
Contributor

@reiniercriel reiniercriel commented May 22, 2026

Summary by Aikido

Security Issues: 0 🔍 Quality Issues: 2 Resolved Issues: 0

🚀 New Features

  • Added OpenRouter AI aggregator detection and reporting, with tests
  • Added Vercel AI Gateway detection and model reporting, including tests

More info

Comment on lines +142 to +149
let parsed: AggregatorRequestModel = serde_json::from_slice(bytes)
.inspect_err(|err| {
tracing::debug!(
error = %err,
"failed to parse openrouter request body as JSON with `model`"
);
})
.ok()?;
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.

The parse_model_field implementation combines serde_json::from_slice, inspect_err with a closure containing tracing::debug!, and .ok()? on a single expression. Split parsing, error logging, and the optional conversion into clearer steps.

Show fix
Suggested change
let parsed: AggregatorRequestModel = serde_json::from_slice(bytes)
.inspect_err(|err| {
tracing::debug!(
error = %err,
"failed to parse openrouter request body as JSON with `model`"
);
})
.ok()?;
let parse_result = serde_json::from_slice(bytes);
if let Err(err) = &parse_result {
tracing::debug!(
error = %err,
"failed to parse openrouter request body as JSON with `model`"
);
}
let parsed: AggregatorRequestModel = parse_result.ok()?;
Details

✨ AI Reasoning
​The code attempts to parse JSON from a byte slice and logs parsing errors using an inline closure inside a chained call. This packs parsing, error inspection with a closure containing a tracing call, and immediate .ok()? conversion onto a single expression, increasing cognitive load when reviewing error flow and return semantics.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment on lines +147 to +154
let parsed: AggregatorRequestModel = serde_json::from_slice(bytes)
.inspect_err(|err| {
tracing::debug!(
error = %err,
"failed to parse vercel-ai-gateway request body as JSON with `model`"
);
})
.ok()?;
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.

The parse_model_field implementation chains serde_json::from_slice, inspect_err with a logging closure, and .ok()? on one expression. Separate parsing, error logging, and optional handling into distinct statements.

Show fix
Suggested change
let parsed: AggregatorRequestModel = serde_json::from_slice(bytes)
.inspect_err(|err| {
tracing::debug!(
error = %err,
"failed to parse vercel-ai-gateway request body as JSON with `model`"
);
})
.ok()?;
let parse_result = serde_json::from_slice(bytes);
if let Err(err) = &parse_result {
tracing::debug!(
error = %err,
"failed to parse vercel-ai-gateway request body as JSON with `model`"
);
}
let parsed: AggregatorRequestModel = parse_result.ok()?;
Details

✨ AI Reasoning
​The code attempts JSON parsing and error logging in a single chained expression: serde_json::from_slice(...).inspect_err(|err| tracing::debug!(...)).ok()?. This bundles parsing, an inline error-inspecting closure that logs details, and immediate ? conversion, making the control flow harder to follow at a glance.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

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