Repository navigation
feat(routes): entry-named counts in /cached-hits; deprecate the *_hits fields (#336) - #465
Merged
Merged
Conversation
…s fields (#336) /cached-hits reported cached_hits, total_hits, valid_hits and expired_hits, which count cache entries, not hits, so the docs had to explain the names. The response now carries entries, total_entries, valid_entries and expired_entries with the same values. The old fields stay until 0.6.0, filled as before, and are marked deprecated in the OpenAPI schema (pydantic Field(deprecated=...)), so generated clients flag them. Closes #336
18 tasks done
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.
Fixes #336
Summary
/cached-hitsreportedcached_hits,total_hits,valid_hitsandexpired_hits. These count cache entries, not hits, so the docs had to explain the names.As the issue proposes, this PR adds correctly named fields and keeps the old ones as deprecated aliases:
entriescached_hitstotal_entriestotal_hitsvalid_entriesvalid_hitsexpired_entriesexpired_hitsdeprecated: truein the OpenAPI schema through pydantic'sField(deprecated=...), with a message naming the replacement, so generated clients and the docs UI flag them. Pydantic's floor (2.7) supports it; thelowestjob checks that.FutureWarningwould reach the server's logs, not the API's consumers. The OpenAPI flag, the docs, thedeprecatedchangelog entry and the release notes are where consumers will see it./cached-hits. Renaming it, for example adding/cached-entries, would be a separate decision.336.added.mdand336.deprecated.md.HTTP_CACHING.md, in English and zh-TW.Follow-up for 0.6.0: remove the four fields and add a section to
MIGRATING_0_6.md.Checklist
The issue above is assigned to me (maintainer's own issue)
Tests under
tests/cover the change. A newTestEntryNamedFieldscovers:expired_entries*_hitsfields deprecatedBreaking the expired count or dropping one deprecation mark fails them. The existing tests on the old fields pass unchanged.
Changelog fragments added
uv run pre-commit run --all-filesanduv run pytest --covpass: 1254 passed, 192 skipped, 93.11% coverage. So do mypy strict,mypy tests,mypy scriptsand bothzensical build --strictruns.Generated by Claude Code