Repository navigation
Accept before/after and RFC 3339 offsets on the v3 advisory list - #106
Merged
rockythorn merged 1 commit intoNov 16, 2026
Conversation
GET /api/v3/advisories/ only read its date filters from before_raw and after_raw, the Python argument names. FastAPI drops unknown query parameters, so a client sending ?after=, the name every other filter on this endpoint and v2's filters.after suggest, got the whole catalog back with no error. CEM's incremental RESF sync does exactly that and walks every page on every run. Read before/after, keep before_raw/after_raw as deprecated fallbacks for existing clients, and reject a request that sets both spellings of one filter with a 400 instead of guessing which one wins. An empty or unparseable before/after is a 400, as it already was for the *_raw names. parse_rfc3339_date only stripped a trailing Z, so an offset such as +00:00 (Python's isoformat() for an aware datetime) or -07:00 produced an aware datetime. fetch_advisories binds it as a naive timestamp and asyncpg refuses to encode an aware value there, so the request failed with a 500 on both the v3 list and v2 filters.before/filters.after. Convert offsets to naive UTC, which is what a Z value already produced, and treat an offset that overflows the datetime range as invalid input.
rockythorn
deleted the
distro-tools/t_feb6e021-apollo-v3-advisories-honor-after-before
branch
November 16, 2026 21:15
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.
GET /api/v3/advisories/only read its date filters frombefore_rawandafter_raw, the Python argument names. FastAPI drops unknown query parameters, so a client sending?after=got the whole catalog back with no error. That name is what every other filter on this endpoint, and v2'sfilters.after, suggest. CEM's incremental RESF sync sendsafter=and so walks every page on every run.A timezone offset also broke both list APIs.
parse_rfc3339_dateonly stripped a trailingZ, so+00:00(Python'sisoformat()for an aware datetime) or-07:00produced an aware datetime.fetch_advisoriesbinds that as$6 :: timestamp, and asyncpg refuses it:The request then fails with a 500. This affects the v3 list (
after_raw/before_raw) and v2filters.after/filters.before.Changes
before/after.before_raw/after_rawkeep working as deprecated fallbacks (deprecatedin OpenAPI). A request that sets both spellings of one filter gets a 400 instead of Apollo guessing which one wins. An empty or unparseable value is a 400, as it already was for the*_rawnames.parse_rfc3339_dateconverts offsets to naive UTC, the same value aZsuffix already produced. An offset that overflows the datetime range is treated as invalid input (400), not a 500. The v2 compat routes share the parser, so they get the same fix. v2's parameter names (filters.before/filters.after) were already right.web/docs/apollo/openapi.mdand the OpenAPI descriptions documentbefore/afterand mark the*_rawnames deprecated.Related: #96 fixes the OSV list's
after=500 insidefetch_advisories. This PR doesn't touch that file, and the two merge without conflicts between them. With both merged, #96'snaive_utc()is a no-op for these routes.Verification
Unit tests:
test_api_advisoriesgained 11 tests (TestListAdvisoriesDateParams) andtest_api_compatgained 3 (TestFetchAdvisoriesCompatDates). They coverZ,+00:00with microseconds,-07:00and+02:30, the plain and*_rawnames, both names at once, and invalid, empty and overflowing values. Eleven of them fail without this change. All 17 CI unit targets pass under Bazel, and pylint scores 10.00 on the changed files.Against Postgres: I ran the real v3, v2 and OSV routers against a local Postgres holding 10,433 advisories, with a cutoff of 2026-11-12T20:00:00:
after=…Zafter=…+00:00after=2026-11-12T13:00:00-07:00after_raw=…Zafter_raw=….160727+00:00before=2023-01-01T00:00:00+00:00after=…&after_raw=…after=badfilters.after=…+00:00filters.after=…-07:00