Repository navigation
feat(apidocs): Add a shared scan and owner lookup for API rule findings - #131117
Merged
akhilp117 merged 2 commits intoNov 18, 2026
Merged
Conversation
This was referenced Nov 13, 2026
DominikB2014
approved these changes
Nov 17, 2026
akhilp117
force-pushed
the
akhilpindiprolu/eng-8866-add-api-findings-scan
branch
from
November 18, 2026 03:53
c6c6d74 to
159ede7
Compare
akhilp117
added a commit
that referenced
this pull request
Nov 18, 2026
…131088) This PR introduces `make api-baseline`, a new make command that writes every S025-S028 finding to `api_exceptions/exceptions.json`. The report card and the upcoming CI job will read from this file. The scan and owner lookup it uses are in #131117. Each entry is one finding (an error founds by flake) signature (rule, path, scope, key) with its count, owner, status, reason and when it was first seen Here's a list of the arguments that can be passed in: - `--files` only rescans the files you pass and keeps everything else as is. Existing entries keep their status, reason and first_seen. It prints what's new, fixed, or changed - `--root` scans another checkout (i.e, an older commit) with the current rules (used for demoing) - `--force` is needed to regenerate the whole file since that resets statuses Renames, deletions, and bad paths with --files: - Entries for a file that's no longer in the checkout are removed and reported as fixed, whether or not that file was listed. So a plain `git diff --name-only` works and `--no-renames` isn't needed anymore - If a removed entry and a new one share the same rule, scope and key, it warns "Possibly moved", since the status and reason don't carry over to the new path - If a file is gone and wasn't listed, it warns that its new path probably needs a rescan, or those findings will show up as new on the next run - Paths that can't be rescanned (outside src/, not .py, or missing with no entries, like a typo) are printed to stderr, and the run exits 1 if none of them can be used If a dev renames a file, its findings show up as fixed under the old path and new findings under the new path. Devs must use `git diff --no-renames` to get the file list and pass that into `--files` so the old path's entries get removed too
akhilp117
added a commit
that referenced
this pull request
Nov 18, 2026
[Linear issue](https://linear.app/getsentry/issue/ENG-9043/build-a-per-team-api-report-card-v0) Stacked on #131117 (the shared scan and owner lookup) so that one needs review firstt. This adds `make api-report-card`, which shows each team its existing API lint findings, so every piece of API debt has a visible owner. It scans `src/` with `collect_findings` and finds each finding's team with `owner_for`. It doesn't need a baseline or any exceptions. **What it prints** - A header with the total, the owner map's date (the file's modification time, since the map has no date inside it) and how many findings are `unowned`, so a stale map is easy to spot - A table with one row per team, sorted by findings, with a column per rule and the number of files. `unowned` is always its own row, last, even when it's 0 - The rule columns are S025-S028 always (S027 has 0 findings but is still checked), plus any other API rule that has findings. So S034 and S021-S023 show up on their own once they report structured output. Until then the header lists them as having no structured findings, so nobody reads them as clean **Options** (through `ARGS`) - `ARGS="--team issues-feed"`: that team's findings, one per line (`file:line rule key in Class.method`), sorted by file and line - `ARGS="--format markdown"`: the same table as markdown, for docs and PR comments **On master today**: 293 findings in 78 files across 18 teams, plus 24 `unowned` findings in 7 files under `src/sentry/core/endpoints/` **Not in v0:** the legacy vs new split and statuses (they depend on how exceptions get stored), trends over time, and running in CI (which needs a decision on where the owner map comes from)
BYK
added a commit
that referenced
this pull request
Nov 20, 2026
Refs #131073 Our OpenAPI docs drift from what endpoints actually return, and nothing catches it. This compares the responses tests get from **public** operations with the schema drf-spectacular generates from the code: - **S036**: the status isn't in the operation's `responses` - **S037**: the JSON body doesn't match that status's schema 304, 429 and 5xx are exempt: a 304 only answers a conditional request, the rate limiter can return a 429 from any endpoint, and a 5xx is a bug rather than part of the contract. S035 is taken by #130924. This stands alone and doesn't touch the API guidelines work in #131117 → #131088 → #131135 → #131407. Findings use the same signature (endpoint file, `EndpointClass.method`, `status:<code>`, owner) and entry shape as that stack's `exceptions.json`, which is where the baseline goes once the stack lands. The pytest plugin is opt-in, with two modes. Report mode records findings and annotates endpoints whose findings aren't baselined. Strict mode also fails the test that got one. The schema is generated while xdist workers start, so it always matches the code and doesn't need node. A new baseline tool adds a run's findings to a baseline file. It only touches the endpoint methods that run called, and keeps reviewed statuses. Backend CI runs in report mode, so nothing blocks merges. CI moves to strict mode together with the baseline. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A3bcd89ea85721d16b9af505e --> -- [View Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3A3bcd89ea85721d16b9af505e) [[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A3bcd89ea85721d16b9af505e/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
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.
Linear issue
This PR adds the logic of scanning files in src and running flake on them, regardless of however the existing findings end up being stored (an
exceptions.jsonfile or inline comments). The upcoming API report card is built on theseWhat's added
tools/api_guidelines/scan.py:collect_findingsscans every file undersrc/with the plugin's structured output (get_api_violations) and returns(path, finding)pairs with repo-relative pathstools/api_guidelines/rules.py:BASELINED_RULES(S025-S028), the rules whose existing findings are kept as legacy debt. The scan doesn't use it: it returns every rule's findings, and each caller picks the rules it needs. The baselined rules keeps only these, while the report card will show every ruletools/api_guidelines/owners.py:owner_forfinds the team that owns a finding from the owner map (make api-owner-map). A finding in a module-level helper, or on a base class that isn't routed, gets its owner throughcaller, the public method that reached it. It falls back tounownedOn master
f362f374645,collect_findingsgives 293 findings, the same total asflake8 --select=S025,S026,S027,S028withSENTRY_INPUT_LINT_ALL=1Once this merges, #131088 will import
collect_findingsfrom here and only keep theexceptions.jsonwriting