Skip to content

refactor: use enums instead of raw strings for job/health status - #685

Open
AkhilVipparla wants to merge 1 commit into
fireform-core:developmentfrom
AkhilVipparla:684-use-enums-instead-of-string-comparison
Open

AkhilVipparla wants to merge 1 commit into
fireform-core:developmentfrom
AkhilVipparla:684-use-enums-instead-of-string-comparison

Conversation

@AkhilVipparla

@AkhilVipparla AkhilVipparla commented Sep 18, 2026 •

Copy link
Copy Markdown

Summary

Part of #684 — Job.status/job_type were still typed as plain str while every
other v1 model (Input, Extraction, Incident, Form, Report) already uses the
generated enums. This retypes Job to match and fixes the raw-string call sites
in routes/jobs.py, services/input.py, tasks/fill.py, and tasks/transcribe.py.

Also adds a HealthState enum (healthy/degraded/unhealthy) for
routes/system.py, which had no backing enum in enums.yaml at all. On the
contract side, BatchStatus.status in form-record.yaml now points at the
shared JobStatus enum instead of duplicating its own inline copy.

All of these are still str subclasses, so JSON responses are unchanged.

Out of scope for this PR: the sort param enum in contracts/path/incidents.yaml
— there's no incidents.py route implemented yet, so there's no actual
string-comparison bug there to fix.

Test plan

  • pytest tests/ — 145 passed, 0 failures
  • ruff check app/ — same 50 pre-existing findings as development, 0 new ones introduced

Job.status/job_type were still typed as plain str while every other v1
model (Input, Extraction, Incident, Form, Report) already uses the
generated JobStatus/JobType/etc enums. Retype Job to match and fix the
four call sites that assigned/compared raw string literals instead
(routes/jobs.py, services/input.py, tasks/fill.py, tasks/transcribe.py).

Also adds a HealthState enum (healthy/degraded/unhealthy) — this value
was compared/assigned as a raw string in routes/system.py with no
backing enum in enums.yaml at all. Contract-side, BatchStatus.status in
form-record.yaml now references the shared JobStatus enum instead of
duplicating its own inline copy.

All of these are still str subclasses, so JSON responses are byte-for-byte
unchanged. Part of fireform-core#684.

This branch has not been deployed

No deployments
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.

1 participant