Skip to content

Commit 7cd5b94

Browse files
LEANDERANTONYclaude
andcommitted
CI: green up the test + frontend jobs
Two unrelated breakages, both diagnosed via a github.com/actions walk after the user noticed every CI run since the redesign merge has been red: Python — `tests/test_error_handling_scenarios.py` The two `admin_refresh_*` scenarios POST to /api/admin/refresh-cache and assert 401/403. They passed locally because `.env` in the repo root populates REFRESH_CACHE_SECRET, so the endpoint reaches the bearer-check branch. CI does not load that .env, so REFRESH_CACHE_SECRET ends up empty and the route's "fail closed" path returns 503 ("Refresh-cache secret not configured on the server.") — never exercising the assertion path. Split the two scenarios out of the parametrized list into standalone test functions that take `monkeypatch` and patch `backend.routers.jobs.REFRESH_CACHE_SECRET = "test-secret"` before invoking the scenario. The other 9 scenarios stay in the parametrized list since they don't need the secret. Frontend — `frontend/src/components/workspace/WorkspaceShell.tsx` The `jd_summary` projection added in commit `e741549` ("Assistant: thread live workspace state into every query") referenced field names that don't exist on the `JobReview` type. Specifically: - `review.title` → JobReview has no title field - `review.location` → no location field either - `review.requirements.*` → no requirements field; the parsed-text breakdown lives at the top level as `hardSkills` / `softSkills` / `mustHaves` TypeScript blocks the Next.js build on this. The Vercel/dev server happens to run with looser types so it kept working locally; CI's `next build` (full type check) failed. Fix: pull title + location from `activeJob` (the JobPosting metadata, which DOES have those structured fields) and use the correct flat field names from JobReview for the counts. When the user pasted a JD manually (no JobPosting), title + location come up empty; the LLM still gets the skill counts. Verified locally: - tests/test_error_handling_scenarios.py: 14/14 pass - npx tsc --noEmit: 0 errors - Build & Deploy was always green (only test+frontend in CI were red), so production was never affected by either bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 18fde26 commit 7cd5b94

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

frontend/src/components/workspace/WorkspaceShell.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,13 +1355,22 @@ export function WorkspaceShell() {
13551355
}
13561356
: null,
13571357
has_jd: Boolean(review),
1358+
// Title + location come from the JobPosting metadata (when
1359+
// the user picked a job from search). Skill counts come from
1360+
// the JobReview's parsed-text breakdown. They live on
1361+
// different objects on purpose: review.{hardSkills,softSkills,
1362+
// mustHaves} is the local heuristic parse of the JD body,
1363+
// whereas activeJob.{title,location} is the structured
1364+
// metadata from the ATS source. activeJob is null on a
1365+
// manually-pasted JD, in which case title/location simply
1366+
// come up empty — the LLM still gets the skill counts.
13581367
jd_summary: review
13591368
? {
1360-
title: review.title || "",
1361-
location: review.location ?? null,
1362-
hard_skills_count: review.requirements?.hard_skills?.length ?? 0,
1363-
soft_skills_count: review.requirements?.soft_skills?.length ?? 0,
1364-
must_haves_count: review.requirements?.must_haves?.length ?? 0,
1369+
title: activeJob?.title ?? "",
1370+
location: activeJob?.location ?? null,
1371+
hard_skills_count: review.hardSkills?.length ?? 0,
1372+
soft_skills_count: review.softSkills?.length ?? 0,
1373+
must_haves_count: review.mustHaves?.length ?? 0,
13651374
}
13661375
: null,
13671376
has_analysis: Boolean(analysisState),

tests/test_error_handling_scenarios.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,14 @@ def _scenario_assistant_answer_unknown_action():
314314
("artifact_export_unsupported_format", _scenario_artifact_export_unsupported_format),
315315
("workspace_analyze_empty_body", _scenario_workspace_analyze_empty_body),
316316
("analyze_jobs_status_missing_job", _scenario_analyze_jobs_status_missing_job),
317-
("admin_refresh_without_bearer", _scenario_admin_refresh_without_bearer),
318-
("admin_refresh_invalid_bearer", _scenario_admin_refresh_invalid_bearer),
317+
# The two admin-refresh bearer scenarios live as separate test
318+
# functions below — they need a `monkeypatch` to set the
319+
# REFRESH_CACHE_SECRET. Without it the endpoint returns 503
320+
# ("Refresh-cache secret not configured") and the bearer-check
321+
# branches we're trying to exercise never run. (Local dev
322+
# happens to pass because `.env` populates the secret; CI
323+
# doesn't ship a `.env`, so the parametrized form failed
324+
# only in CI.)
319325
("resume_builder_export_400_real_message", _scenario_resume_builder_export_returns_400_with_real_message),
320326
("save_workspace_unauthenticated", _scenario_save_workspace_unauthenticated),
321327
("assistant_answer_unknown_action", _scenario_assistant_answer_unknown_action),
@@ -327,6 +333,23 @@ def test_error_scenario(name, scenario_fn):
327333
scenario_fn()
328334

329335

336+
def test_admin_refresh_without_bearer(monkeypatch):
337+
"""Endpoint must reject an unauthenticated POST with 401/403.
338+
339+
Patches REFRESH_CACHE_SECRET so the bearer-check branch is
340+
actually reached (without a configured secret the endpoint
341+
short-circuits with a 503).
342+
"""
343+
monkeypatch.setattr("backend.routers.jobs.REFRESH_CACHE_SECRET", "test-secret")
344+
_scenario_admin_refresh_without_bearer()
345+
346+
347+
def test_admin_refresh_invalid_bearer(monkeypatch):
348+
"""Endpoint must reject a wrong bearer with 401."""
349+
monkeypatch.setattr("backend.routers.jobs.REFRESH_CACHE_SECRET", "test-secret")
350+
_scenario_admin_refresh_invalid_bearer()
351+
352+
330353
def test_resume_upload_with_invalid_base64(monkeypatch):
331354
_scenario_resume_upload_with_invalid_base64(monkeypatch)
332355

0 commit comments

Comments
 (0)