Repository navigation
fix(inquiries): make the application inquiry page actually load - #475
Merged
Merged
Conversation
The route rendered a red "Unable to load inquiry" because
`client.inquiries.getByApplication()` did not exist. An
`as unknown as InquiryCapabilityClient` cast in inquiries-sdk-hooks.ts silenced
the missing-method type error, so it failed at runtime instead. Only the legacy
tRPC router had a real implementation.
## Server
New GET /v1/inquiries/by-application/{applicationId}, ported from the tRPC
procedure, including its access rule: the applicant, the hiring organization's
owner, or a user with a role assignment scoped to that organization. 404 for
"no such application" and 403 for "not yours" are returned distinctly instead of
being collapsed, and a query failure is 500 rather than being mistaken for
absence. Returns the object bare, not under `data`, because the SDK hands the
body back verbatim and callers read `.inquiry` off it.
It also returns application/candidate/job/capabilityQuestions, because the
office view reads `data.candidate` and `data.job`; omitting them would have
silently degraded that page to "Candidate" / "Job" placeholders.
## Client
Cast removed, so this call is type-checked against the real SDK surface. That
alone caught two type inaccuracies the cast had been hiding, both corrected
against the live schema:
* InquiryComment was missing sender_id, content, read_by (all NOT NULL)
* capabilityResponses denied null on response_value / response_text, which
core.inquiry_capability_responses allows
## Empty state
Both inquiry routes treated "no inquiry exists" as a failure — the same red
error branch as a fetch error and a bad application id. Since most applications
never have an inquiry raised, the ordinary case was reported to the user as
broken. They are now separate branches, and the error branch shows the actual
message instead of swallowing it.
## Two schema bugs found on the way
Validating each PostgREST select against the live database — rather than
trusting the tRPC source — turned up that the legacy procedure selects
`applied_at` and `application_score`, and neither column exists on
core.applications. That query would 400 outright. The real columns are
`created_at` and `score_total`; the response keys are unchanged so the views do
not care.
Separately, the pre-existing GET/POST /v1/inquiries read `core.inquiries`, a
table that does not exist in the database at all. Both endpoints 500. That is a
different concept from core.application_inquiries (this feature) and is filed
separately rather than fixed here.
## Verification
- 12 new tests covering the access decisions and the response mapping, passing
standalone and inside the full suite
- Every PostgREST select string executed against the live local database
- scf-core and apps/scaffald typecheck clean with the cast gone; deno check on
the route adds 0 errors to its 14 pre-existing ones
- api suite: 119 passed / 59 failed before, 129-130 passed / 60-61 failed after.
Two consecutive runs of identical code gave 129/61 and 130/60, so the existing
suite is flaky at about +/-2; all 12 of mine pass in every run
Not verified through the browser: the local edge runtime serves the primary
working tree, which currently holds an unrelated in-progress changeset from a
concurrent session, so I could not exercise the full HTTP path against my build.
Fixes the reported symptom in #443; the remaining 15 unported methods stay open
there. Refs #440
Co-Authored-By: Claude Opus 5 <[email protected]>
Closed
This was referenced Jul 30, 2026
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.
Fixes the reported symptom in #443. Part of #440.
Why it was broken
client.inquiries.getByApplication()did not exist. The call site hid that:The cast silenced the missing-method error, so it failed at runtime and the route fell into its
error || !databranch and printed a red "Unable to load inquiry". Only the legacy tRPC router had a real implementation.Server
New
GET /v1/inquiries/by-application/{applicationId}(companion SDK method in Scaffald/sdk#11), ported from the tRPC procedure including its access rule — the applicant, the hiring organization's owner, or a user with a role assignment scoped to that organization.Improvements over the port:
data. The SDK hands the body back verbatim and callers read.inquiryoff it.application/candidate/job/capabilityQuestions, because the office view readsdata.candidateanddata.job— omitting them would have quietly degraded that page to "Candidate" / "Job" placeholders.Client
Cast removed, so the call is type-checked against the real SDK surface. That alone caught two inaccuracies the cast had been hiding, both corrected against the live schema:
InquiryCommentwas missingsender_id,content,read_by— allNOT NULLincore.inquiry_comments.capabilityResponsesdeniednullonresponse_value/response_text, whichcore.inquiry_capability_responsesallows.The empty state was the other half of the bug
Both inquiry routes treated "no inquiry exists" as a failure — the same red branch as a fetch error and as a bad application id.
core.application_inquiriesis empty in seed data, and most real applications never have an inquiry raised, so the ordinary case was being reported to users as broken. Now three distinct states, and the error branch surfaces the actual message instead of swallowing it.Two schema bugs found by verifying rather than trusting
I ran every PostgREST select against the live local database instead of trusting the tRPC source:
applied_atandapplication_scoreare not oncore.applications— that query 400s outright:created_atandscore_total. Response keys are unchanged, so the views don't care.core.inquiriesdoes not exist at all. The pre-existingGET/POST /v1/inquiriesboth read it, so both 500. That is a different concept fromcore.application_inquiries(this feature) — sender/recipient messaging vs. the ATS capability inquiry. Filed separately; not fixed here.Verification
scf-coreandapps/scaffaldtypecheck clean with the cast gone.deno checkon the route adds 0 errors to its 14 pre-existing ones (all fromc.get()inferring asnever, sinceauthMiddlewareuses an untypedContext— repo-wide, out of scope).Not verified through the browser. The local edge runtime serves the primary working tree, which currently holds an unrelated in-progress changeset from a concurrent session, so I could not exercise the full HTTP path against my own build without disturbing it. The query strings are individually verified against the live database, but I have not seen the page render and am not claiming otherwise.
Still open on #443
The 15 other missing methods and their endpoints (
createTemplate,applyTemplate,getSmartDefaults,createBulk,getMultiple,send,addComment,acceptSection,submitCapabilityResponse,update,changeStatus, …), plus the lint rule banningas unknown ason SDK clients. This PR fixes the reported page; the epic stays open.