Skip to content

feat: new http api v3 - #248

Open
kairoaraujo wants to merge 5 commits into
feat/new-http-api-v2from
feat/new-http-api-v3
Open

feat: new http api v3#248
kairoaraujo wants to merge 5 commits into
feat/new-http-api-v2from
feat/new-http-api-v3

Conversation

@kairoaraujo

@kairoaraujo kairoaraujo commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

New http for /api/v3

Changes

  • src/djehuty/services/ (git, email, handles, permissions): framework-neutral services the v3 endpoints need — git repository access and smart-HTTP, collaborative-permission checks, transactional e-mail (via config.email_interface), and handle.net PID registration. Git statistics (languages/contributors) reproduce the legacy byte-weighted / GitHub-style payloads and caching.
  • src/djehuty/api/v3/: the v3 surface as resource-based routers mirroring v2 (datasets, collections, profile, reviews, statistics, explore, admin, ssi, ro_crates, codemeta, authors, groups, accounts, tags, files, git), each reproducing its legacy handler's side effects AS-IS (db writes, cache invalidations, e-mails, DataCite DOI flow, git/filesystem effects), with OpenAPI examples.
  • src/djehuty/application.py, route_groups.py, configs: register and mount the api-v3 group with versioned API docs (/api/docs/v2, /api/docs/v3) driven by a single API_VERSIONS list.
  • tests/unit/: v3 group tests (registration, legacy-override, umbrella mount) plus pinned side-effect call shapes; dispatch/v2-group tests adjusted now that /v3 resolves to the new stack.
  • docs/http-migration-api-v3-side-effects.md: the v3 side-effect catalog — scaffolding documenting what each route must reproduce, the AS-IS deviations kept on purpose, and the remaining deferral.

Approval Checklist

  • I agree to follow Djehuty's code of conduct.
  • I have read and I have follow the code contribution workflow.
  • Code style and conventions were respected.
  • Documentation has been updated where needed (README, docs, or examples).
  • Review approved by at least one maintainer.
  • Merge readiness (PR is squashed into a single commit and follows the commit template).

Closes #254
Closes #252

Screenshots (optional)

Before/After visuals, UI changes, or relevant logs.

Notes (optional)

Additional context, caveats, or follow-up tasks.

@kairoaraujo
kairoaraujo force-pushed the feat/new-http-api-v3 branch 2 times, most recently from 65259de to f21ff03 Compare August 8, 2026 03:27
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.77687% with 1294 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.54%. Comparing base (11f4f37) to head (61ff629).

Files with missing lines Patch % Lines
src/djehuty/services/git.py 10.47% 187 Missing and 1 partial ⚠️
src/djehuty/api/v3/git.py 24.28% 156 Missing and 3 partials ⚠️
src/djehuty/api/v3/datasets/files.py 16.66% 140 Missing ⚠️
src/djehuty/api/v3/datasets/publishing.py 27.80% 129 Missing and 6 partials ⚠️
src/djehuty/api/v3/profile.py 26.19% 93 Missing ⚠️
src/djehuty/api/v3/collections/publishing.py 21.05% 60 Missing ⚠️
src/djehuty/api/v3/admin.py 25.00% 54 Missing ⚠️
src/djehuty/api/v3/ssi.py 20.68% 46 Missing ⚠️
src/djehuty/api/v3/datasets/authors.py 30.76% 36 Missing ⚠️
src/djehuty/api/v3/statistics.py 29.16% 34 Missing ⚠️
... and 23 more
Additional details and impacted files
@@                   Coverage Diff                    @@
##           feat/new-http-api-v2     #248      +/-   ##
========================================================
+ Coverage                 23.96%   25.54%   +1.57%     
========================================================
  Files                        67      103      +36     
  Lines                     12412    14366    +1954     
  Branches                   2307     2574     +267     
========================================================
+ Hits                       2975     3670     +695     
- Misses                     9140    10368    +1228     
- Partials                    297      328      +31     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kairoaraujo
kairoaraujo force-pushed the feat/new-http-api-v3 branch from f21ff03 to 641bd04 Compare August 8, 2026 04:16
Comment thread src/djehuty/api/v3/admin.py Dismissed
Comment thread src/djehuty/api/v3/datasets/files.py Dismissed
Comment thread src/djehuty/api/v3/datasets/files.py Dismissed
Comment thread src/djehuty/api/v3/git.py Dismissed
Comment thread src/djehuty/api/v3/profile.py Dismissed
Comment thread src/djehuty/services/git.py Dismissed
Comment thread src/djehuty/services/git.py Dismissed
Comment thread src/djehuty/utils/convenience.py Dismissed
Comment thread src/djehuty/api/v3/ssi.py Dismissed
Comment thread src/djehuty/api/v3/ssi.py Dismissed
Comment thread tests/unit/test_api_v3_group.py Fixed
@kairoaraujo
kairoaraujo force-pushed the feat/new-http-api-v3 branch from 641bd04 to a4481bc Compare August 8, 2026 08:14
@kairoaraujo

Copy link
Copy Markdown
Collaborator Author
  • git_info_refs path traversal: genuinely fixed: it built a filesystem path from git_uuid before validation. Added an is_valid_uuid guard (and one in create_repository). Valid ids are unaffected; only malformed input is now rejected (404), matching legacy's "unknown repo" outcome.
  • Other path findings (profile, files, admin): false positives: the ids are server-generated or already is_valid_uuid-validated / DB-resolved before any file access.
  • ReDoS (convenience.py): verbatim from the legacy search tokenizer, non-nested regex, reproduced as-is.
  • SSI redirect/cookie + docs XSS: faithful ports of existing legacy behavior.
  • Also removed an unused import in the new test.

@kairoaraujo
kairoaraujo force-pushed the feat/new-http-api-v3 branch from a4481bc to a0604b3 Compare August 8, 2026 08:40
@kairoaraujo
kairoaraujo marked this pull request as ready for review August 8, 2026 08:56
@kairoaraujo
kairoaraujo requested a review from 641e16 August 10, 2026 10:03
The v3 endpoints build on a few framework-neutral helpers that v2 did not
need: git repository access, collaborative-permission checks, transactional
e-mail, and handle.net PID registration. The e-mail service reuses the mail
sender configured on the legacy server, shared through config.email_interface
(set in web/ui.py, declared in the runtime config).
Organize the v3 surface into resource-based packages that mirror the v2 layout:
a datasets/ package (listing, publishing, references, tags, files, authors,
collaborators, badges), a collections/ package, and focused top-level modules
(profile, reviews, statistics, explore, admin, ssi, ro_crates, codemeta,
authors, groups, accounts, tags, files, git). Each router carries a consistent
"V3 / ..." tag, and endpoints document request/response examples drawn from
real responses.
Register the api-v3 route group and mount the v3 router, and set api-v3 to the
new stack in the shipped configs. The API docs gain a version selector: one
/api/docs page with a v3/v2/all dropdown plus bookmarkable /api/docs/v2 and
/api/docs/v3 pages, each backed by a schema filtered to that version. A single
API_VERSIONS list drives all of it, so adding or retiring a version is a
one-line change. The authentication guide now covers both v2 and v3 and shows
how to obtain a token. Unhandled errors are logged with a traceback.
With api-v3 registered as a route group, /v3 paths now resolve to the new
stack, so the dispatch and v2-group tests use a genuinely unregistered path to
assert the fallback-to-legacy behaviour.
Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>
@kairoaraujo
kairoaraujo force-pushed the feat/new-http-api-v3 branch from a0604b3 to 61ff629 Compare August 13, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[IMPROVEMENT]: Add new http for /api/v3 [DOCUMENTATION]: OpenAPI for /api/v2 and /api/v3

2 participants