Skip to content

docs: record userinfo, check-config decisions - #704

Merged
uniqueg merged 2 commits into
devfrom
chore/userinfo-check-config-docs
Nov 5, 2026
Merged

uniqueg merged 2 commits into
devfrom
chore/userinfo-check-config-docs

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Closes #702

Light lane: docs only. Both points are decided in favour of the current behaviour, with the docs now saying so.

Coalescing user info: no

Concurrent cache misses for one token keep fetching separately.

  • Little gain: the extra fetches only occur for the same token within one process, in the short window of a miss, so they are bounded by the threads serving requests, per token and TTL. With userinfo_cache_ttl: 0 and validate_userinfo, every request must fetch anyway, so sharing would not apply there. No report of load on an issuer prompted this.
  • Real cost, in security code: a follower would wait on another request's fetch. It must not take a response that started before a revocation it should see, so it needs the rule for cache entries applied at the point of joining, and a leader's failure or timeout must not become the follower's 401, so followers need their own fallback fetch, adding up to another timeout to their wait. That is new locking and failure paths in _get_userinfo, which has just got its ordering guarantees right.

Can be reopened if an issuer's rate limits become a problem in a deployment.

check-config and the web app: stays

check-config keeps calling create_app() with the startup switches off. The checks work on the app: register_openapi() registers specifications with the Connexion app, register_access_control() adds to it, check_service_info() takes the Flask app, and CORS and opt-in headers are set on it. Running them without an app would mean a second code path that can drift from what startup really does, which is what the command is there to check. The app is never served.

Verification

mkdocs build --strict: passed. No code changed.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Document the accepted user-info caching and check-config behavior decisions.

Enhancements:

  • Document that concurrent user-info cache misses for the same token fetch independently.
  • Clarify that check-config creates the application to run startup checks, including the gateway plugin-store exception.

Documentation:

  • Update authentication and CLI documentation to record the decisions around user-info request coalescing and check-config application setup.

Concurrent misses of user info keep their own fetches, and check-config
keeps creating the app, as its checks need it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Documentation records two decisions: concurrent userinfo cache misses remain independent, and check-config continues creating an application so validation runs against the same configuration and objects used at startup without serving the app.

Sequence diagram for independent userinfo cache misses

sequenceDiagram
    participant RequestA
    participant RequestB
    participant Userinfo
    participant Issuer

    par concurrent request A
        RequestA->>Userinfo: _get_userinfo
        Userinfo->>Issuer: GET /userinfo
        Issuer-->>Userinfo: user info
        Userinfo-->>RequestA: user info
    and concurrent request B
        RequestB->>Userinfo: _get_userinfo
        Userinfo->>Issuer: GET /userinfo
        Issuer-->>Userinfo: user info
        Userinfo-->>RequestB: user info
    end
Loading

Sequence diagram for check-config application-backed validation

sequenceDiagram
    participant CLI as check-config
    participant App
    participant StartupChecks

    CLI->>App: create_app
    CLI->>StartupChecks: register_openapi
    StartupChecks->>App: register_openapi
    CLI->>StartupChecks: register_access_control
    StartupChecks->>App: register_access_control
    CLI->>StartupChecks: check_service_info
    StartupChecks->>App: check_service_info
    Note over CLI,App: App is validated but never served
Loading

File-Level Changes

Change Details Files
Document the deliberate non-coalescing behavior for concurrent userinfo cache misses.
  • Explain that requests sharing a token fetch independently when no cached userinfo exists.
  • Describe the resulting per-thread burst and timeout behavior.
docs/authentication.md
Clarify that check-config validates startup checks against a created but unserved application.
  • State that the command creates the app without serving it or writing to the database.
  • Explain that specifications, access-control, service-info, and related startup checks operate on that app.
docs/cli.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5eb4f70) to head (7f55088).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #704   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           66        66           
  Lines         8588      8588           
=========================================
  Hits          8588      8588           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@uniqueg
uniqueg marked this pull request as ready for review November 5, 2026 06:44

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/cli.md" line_range="56-58" />
<code_context>
 Loads and validates the configuration and runs the startup checks of the app and, if
 `jobs` is set, of its workers. It runs `Foca.create_app()` without serving the app and
-without writing to the database, so it's fit as a CI or Helm test step. Checks that your
+without writing to the database, so it's fit as a CI or Helm test step. It does create
+the app, as the checks need it: specifications are checked by registering them with the
+app, and the checks of access control and the service info work on it. Checks that your
 app's functions run on startup (e.g., [fields of the service info computed at
 runtime](configuration/service-info.md)) run too, and what they need must be available.
</code_context>
<issue_to_address>
**Config check writes to plugin store**

When `check-config` runs for a gateway app with a plugin-store backend and no `db` section, `disable_startup_writes()` leaves `db` as `None`, so `Foca.create_app()` treats the missing database config as permission to run `host.setup_store()`, which creates indexes and caps expiry. `setup_store()` logs and swallows database errors, so `check-config` can mutate the store or exit successfully after setup fails.

Make the no-startup-writes switch disable plugin-store setup independently of whether `db` is configured, or document the exception.
</issue_to_address>

Linked issues

#702 chore: userinfo coalescing, check-config app use · 3 of 3 met

# Requirement Status Notes
1 Decide whether concurrent user-info cache misses for one token should share a fetch. ✅ Met The decision is to keep separate fetches, and docs/authentication.md records that concurrent cache misses fetch independently.
2 Decide whether check-config should create the web app for its checks. ✅ Met The decision is to keep creating the app, and docs/cli.md explains that checks run against it without serving it.
3 If behavior changes, include tests and documentation. ✅ Met The PR keeps the existing behavior and documents both decisions; no behavior change requiring tests is made.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: docs/cli.md:58


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/cli.md Resolved

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 32bcdba into dev Nov 5, 2026
58 checks passed
@uniqueg
uniqueg deleted the chore/userinfo-check-config-docs branch November 5, 2026 06:57
@uniqueg uniqueg added this to the v0.22.0 milestone Nov 9, 2026
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.

chore: userinfo coalescing, check-config app use

1 participant