API: Add v2 endpoints with query-parameter EIDs - #44
Merged
Conversation
JakubMagda
commented
Jul 28, 2026
Collaborator
- Add v2_router with EID passed as query parameter instead of path
- Fixes 404 errors for EIDs containing '/' (e.g., IPv6 CIDR notation)
- New endpoints under /entity/v2/ prefix
- Add tests in tests/test_api/test_v2_api.py
- Update docs/api.md with v2 API documentation
- v1 API remains unchanged and functional
- Add v2_router with EID passed as query parameter instead of path - Fixes 404 errors for EIDs containing '/' (e.g., IPv6 CIDR notation) - New endpoints under /entity/v2/ prefix - Add tests in tests/test_api/test_v2_api.py - Update docs/api.md with v2 API documentation - v1 API remains unchanged and functional
The v1 entity router contains dynamic /{etype}/{eid} routes. While v2 is
mounted below /entity/v2, registering v1 first lets those catch-all routes
consume requests intended for v2 and interpret "v2" as an entity type.
Mount v2 first so its routes take precedence. Also accept entity GET and
DELETE requests without a trailing slash, avoiding redirects and supporting
both URL forms consistently.
Replace isolated TestClient smoke checks with the repository's unittest API harness so the tests are discovered by the standard API test runner and exercise the running API, worker, queue, and database together. Create an entity whose string EID contains path separators, then verify its read, update, TTL, and delete flows through v2. This proves query parameters preserve the EID end to end instead of merely checking that routes do not return 404. Keep datetime imports at module scope and cover validation plus both trailing-slash forms.
Using /entity/v2 leaves the version marker inside the v1 namespace, where it
can conflict with dynamic /entity/{etype}/{eid} routes and makes correctness
depend on router registration order.
Move the endpoints to /v2/entity so the API versions have disjoint prefixes.
Update integration tests and documentation to use the new paths. Let curl
encode query parameters in the examples to demonstrate safe handling of EIDs
that contain URL-significant characters.
V1 and v2 differ only in whether EIDs arrive in the path or query, so delegate both route sets to shared handlers while preserving transport-specific validation.
xsedla1o
approved these changes
Jul 28, 2026
xsedla1o
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for getting this started, good direction for the fix! I fixed any minor issues that were remaining.
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.