Skip to content

Explain uninspected models on rate-limited requests - #36

Merged
mitchins merged 2 commits into
mainfrom
feature/rate-limit-model-observation
Jul 21, 2026
Merged

mitchins merged 2 commits into
mainfrom
feature/rate-limit-model-observation

Conversation

@mitchins

@mitchins mitchins commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • derive a presentation-only model observation status for limiter-terminal logs
  • show “Not inspected (rate limited before body)” across dashboards and request details
  • preserve pre-body admission, raw model fields, persistence, filters, and graphs

Root cause

Rate limiting intentionally runs before JSON body parsing. A rejected request therefore has no observed model, and the dashboard previously rendered the unexplained fallback N/A.

Validation

  • Python 3.11 unit: 931 passed, 1 skipped
  • Python 3.12 unit: 931 passed, 1 skipped
  • Python 3.12 integration: 41 passed, 8 skipped
  • Ruff and git diff --check passed
  • independent adversarial review: PASS

Summary by CodeRabbit

  • New Features

    • Request logs and request detail views now show a clear “Not inspected (rate limited before body)” label when model details weren’t available due to early rate limiting.
    • Dashboard, project, recent-requests, and request-detail screens render this status consistently in the Model area.
  • Bug Fixes

    • Rate-limited requests no longer parse or expose request-body contents before rejection.
    • Request-log model observation now accurately reflects early limiter outcomes, preventing incorrect model labeling.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 182139dc-8587-42e3-a465-7c2327f1c6af

📥 Commits

Reviewing files that changed from the base of the PR and between 49453d8 and 682f7cc.

📒 Files selected for processing (2)
  • smolrouter/templates/client_dashboard.html
  • tests/unit/test_app.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • smolrouter/templates/client_dashboard.html
  • tests/unit/test_app.py

📝 Walkthrough

Walkthrough

The request pipeline now records not_inspected_rate_limit when rate limiting blocks a request before body parsing. Serialized request data and request-related pages display this status instead of implying a model was observed.

Changes

Model observation status

Layer / File(s) Summary
Derive and serialize observation status
smolrouter/app.py
Adds the observation-status constant and derives not_inspected_rate_limit for rate-limiter entries without model fields; serialized request summaries and detail fields include it.
Propagate status to request views
smolrouter/app.py, smolrouter/templates/*.html
Passes the status into request detail and dashboard views, which render “Not inspected (rate limited before body)” while preserving existing model fallbacks.
Validate pre-body rate-limit behavior
tests/unit/test_app.py
Verifies body parsing is skipped, log fields remain unset, status serialization is correct, and affected pages render the new message.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RateLimiter
  participant RequestLog
  participant WebUI
  Client->>RateLimiter: submit request
  RateLimiter->>RequestLog: record terminal rejection without body inspection
  RequestLog->>WebUI: serialize model_observation_status
  WebUI->>Client: render not-inspected message
Loading

Possibly related PRs

  • mitchins/SmolRouter#35: Adds the early rate-limiter admission behavior that produces terminal outcomes consumed by this status handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: showing uninspected model status for rate-limited requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/rate-limit-model-observation

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new model_observation_status field to identify and explain requests that were rate-limited before their body could be inspected. This status is derived when the upstream URL is 'rate-limiter' and no models are present, and is displayed across various dashboard templates. The review feedback points out that the CSS class .cell-secondary used in client_dashboard.html is undefined in that file, which will lead to inconsistent styling, and suggests using inline styles as a workaround.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +205 to +207
if (observationStatus === 'not_inspected_rate_limit') {
return '<span class="cell-secondary">Not inspected (rate limited before body)</span>';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The CSS class .cell-secondary is used here to style the fallback message for uninspected models, but this class is not defined in the <style> block of client_dashboard.html (unlike index.html which defines it locally). This will cause the text to render without the intended gray, smaller font styling on the client dashboard.

Since modifying the <style> block is outside the modified diff hunks, we can apply inline styles directly to the <span> to ensure consistent rendering.

            if (observationStatus === 'not_inspected_rate_limit') {
                return '<span style="font-size: 0.75rem; color: #666;">Not inspected (rate limited before body)</span>';
            }

@codecov

codecov Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.67%. Comparing base (d39948a) to head (682f7cc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   75.43%   75.67%   +0.23%     
==========================================
  Files          37       37              
  Lines       10275    10280       +5     
  Branches     1599     1600       +1     
==========================================
+ Hits         7751     7779      +28     
+ Misses       1939     1913      -26     
- Partials      585      588       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mitchins
mitchins marked this pull request as ready for review July 21, 2026 01:56
@sonarqubecloud

Copy link
Copy Markdown

@mitchins
mitchins merged commit 811ee3c into main Jul 21, 2026
12 checks passed
@mitchins
mitchins deleted the feature/rate-limit-model-observation branch July 21, 2026 02:11
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