Skip to content

refactor(api): enforce enums over string literals on openapi surface#38009

Merged
asukaminato0721 merged 1 commit into
mainfrom
fix/openapi-enum-conversions
Jun 26, 2026
Merged

refactor(api): enforce enums over string literals on openapi surface#38009
asukaminato0721 merged 1 commit into
mainfrom
fix/openapi-enum-conversions

Conversation

@GareArc

@GareArc GareArc commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Replace raw string literals with enum members on the /openapi/v1 surface for type enforcement.

  • New CallerKind StrEnum for caller_kind (account/end_user) — kept distinct from CreatorUserRole despite shared values (different domain: authenticated principal vs. resource authorship).
  • Reuse AppStatus.NORMAL for app status checks (App.status is already typed Mapped[AppStatus]).
  • Reuse AccountStatus.ACTIVE for membership status check.

Device-flow RFC 8628 dict responses left as-is — intentionally outside the OpenApiErrorCode type system.

7 files, no behavior change. ruff clean; 435 openapi unit tests pass.

@GareArc GareArc requested a review from QuantumGhost as a code owner June 26, 2026 05:29
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 51.34% 51.34% 0.00%
Strict coverage 50.85% 50.85% 0.00%
Typed symbols 30,576 30,576 0
Untyped symbols 29,255 29,255 0
Modules 2930 2930 0

Replace raw string comparisons on the /openapi/v1 surface with enum
members for type safety:

- New CallerKind StrEnum for caller_kind (account/end_user); distinct
  from CreatorUserRole despite shared values.
- Reuse AppStatus.NORMAL for app status checks.
- Reuse AccountStatus.ACTIVE for membership status check.
@GareArc GareArc force-pushed the fix/openapi-enum-conversions branch from 2bc7802 to 868e462 Compare June 26, 2026 05:32
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 26, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.28%. Comparing base (f4e832f) to head (868e462).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
api/controllers/openapi/apps_permitted_external.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #38009   +/-   ##
=======================================
  Coverage   85.28%   85.28%           
=======================================
  Files        4938     4938           
  Lines      256070   256074    +4     
  Branches    48559    48559           
=======================================
+ Hits       218389   218395    +6     
+ Misses      33434    33432    -2     
  Partials     4247     4247           
Flag Coverage Δ
api 85.57% <95.45%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Merged via the queue into main with commit fa6f4b0 Jun 26, 2026
36 checks passed
@asukaminato0721 asukaminato0721 deleted the fix/openapi-enum-conversions branch June 26, 2026 06:03
GareArc added a commit that referenced this pull request Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants