docs: complete the /metrics token and response documentation - #159
Merged
aditeyabaral merged 3 commits intoSep 13, 2026
Merged
Conversation
The section only showed `docker run -e`, which left the local mechanism to be guessed. A token in `.env` is the natural guess and it does not work: `.env` is read by the test suite, never by the application, so it looks configured while the endpoint stays open. Both are now stated. Dropped the `openssl rand -hex 32` line with it. How to generate a token is the reader's choice, not something this project needs an opinion on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VU7YUhP71KSsotWQ1H7CRH
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VU7YUhP71KSsotWQ1H7CRH
aditeyabaral
force-pushed
the
docs/caller-facing-metrics-auth
branch
from
September 13, 2026 19:13
993ac07 to
cefab72
Compare
Three gaps, found by checking the section against what the endpoint actually does rather than by rereading it. **The three states of the token are now a table.** Unset and set were described in prose; what happens to a credential sent to an *unconditionally open* endpoint was not written down anywhere. It is ignored rather than rejected, which matters to anyone pointing a scraper at more than one environment. The blank case moves into the same table from a trailing sentence, so all three sit together. **`/metrics` had no response-code table** where every other endpoint documents one, and `500` was absent from the README entirely despite being in the published schema. The table now lists 200, 400, 401 and 500 with the condition for each. **The Authorize button went unmentioned**, which is how most people will first try the token, and it needs the value pasted with no `Bearer ` prefix. Also trimmed the sentence that repeated what the new table says. Every claim in the section was checked against a running server, in both the configured and unconfigured states, including that `fmt` validation and the token are independent: a valid token with a bad `fmt` is a 400, no credential is a 401. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VU7YUhP71KSsotWQ1H7CRH
42 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
Documentation only. The
/metricssection was audited against what the endpoint actually does —by extracting every metric family and JSON field from the code and checking each appears, and by
exercising the endpoint in every configuration — rather than by rereading it. All 24 metric
families and all 20 JSON fields were already covered. Four things were not.
1. Only
docker run -ewas shown, so the mechanism for a local run was left to be guessed —and the natural guess is a line in
.env, which silently does not work..envis read by the testsuite, never by the application, so the endpoint stays open while looking configured. Both the
working local form and that caveat are now written down.
The
openssl rand -hex 32suggestion is dropped with it. How to generate a token is the reader'schoice, not something this project needs an opinion on.
2. The three states of the token are now a table. Unset and set were described in prose, but
what happens to a credential sent to an endpoint that requires none was written down nowhere — it
is ignored rather than rejected, which matters to anyone pointing one scraper at several
environments. The blank case joins them from a trailing sentence, so all three sit together.
METRICS_TOKEN/metrics3.
/metricshad no response-code table, where every other endpoint documents one, and500was missing from the README entirely despite being in the published schema. It now lists
200,400,401and500with the condition for each.4. The Authorize button went unmentioned — the way most people will first try the token, and it
needs the value pasted with no
Bearerprefix, since Swagger adds that itself.No behaviour change. The contract is unchanged from #158: a configured token is enforced, an
unset or blank one means no check.
🧱 Type of Change
requirements.txt,pyproject.toml🧪 How Has This Been Tested?
tests/unit/)tests/functional/)tests/integration/)276 tests, 100.00% coverage, unchanged — no code is touched. Completeness was checked
programmatically against
FAMILIESandMetricsModel.model_fields, not by eye.pre-commit run --all-filespasses 12/12 hooks.
The claims the README now makes were each checked against a running server, since documenting them
is the whole point of the change:
/metrics200, and a credential sent anyway is ignored rather than rejectedMETRICS_TOKEN=(blank)200— blank counts as unsetMETRICS_TOKEN=<token> uv run python -m app.app401bare,401wrong,200correct, bothfmtvaluesdocker runwithout-e200docker run -e METRICS_TOKEN=…401bare,200correct.envonly200— the app never reads the file, which is the caveat documented here?fmt=xml400—fmtvalidation and the token are independent?fmt=xml400401bare,200correct — verified live✅ Checklist
scripts/run_tests.py)pre-commit run --all-files).envvars updated (if applicable)scripts/benchmark/benchmark_requests.py)Unchecked items carry no work: no code, so no docstrings and no new tests; no new variables; and
nothing on a request path a benchmark measures.
🛠️ Affected API Behaviour
app/app.py– Modified/authenticateroute logicapp/pesu.py– Updated scraping or authentication handlingOnly
README.md.🧩 Models
app/models/request.py– Input validation or request schema changesapp/models/response.py– Authentication response formattingapp/models/profile.py– Profile extraction logic🐳 DevOps & Config
Dockerfile– Changes to base image or build process.github/workflows/*.yaml– CI/CD pipeline or deployment updatespyproject.toml/requirements.txt– Dependency version changes.pre-commit-config.yaml– Linting or formatting hook changesProject version only, 4.3.0 → 4.4.0, plus the matching
uv.lock. No dependency changes.📊 Benchmarks & Analysis
scripts/benchmark/benchmark_requests.py– Performance or latency measurement changesscripts/benchmark/analyze_benchmark.py– Benchmark result analysis changesscripts/run_tests.py– Custom test runner logic or behavior updates🧠 Additional Notes
Two things were tried in this branch and deliberately dropped.
Rewriting the Swagger strings. The Authorize dialog and the documented
401nameMETRICS_TOKENand describe a server-side environment variable, which a caller reading Swaggercannot act on. They were rewritten to describe the contract instead, then reverted at the
maintainer's preference — the explicit, mechanism-naming version is the wanted one. Not worth
revisiting.
load_dotenv()in the application. Making.envconfigure a running server would mean movingpython-dotenvout of the dev group into the runtime dependencies, since the image is built withuv sync --no-dev, and it would make a local run demand a token the moment a developer put onein
.env— the opposite of what local development wants. DocumentingMETRICS_TOKEN=<token> <command>covers the case with no dependency and no surprise.One finding worth keeping from that attempt, should anyone revisit it:
load_dotenv()resolvesagainst the working directory under
python -m, not the package. A server started fromanywhere but the repository root would have loaded nothing and served metrics openly while
appearing configured.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VU7YUhP71KSsotWQ1H7CRH