fix(surveys): show a closed state instead of a generic error (Issue 1460) - #1471
Draft
leahpeker wants to merge 2 commits into
Draft
fix(surveys): show a closed state instead of a generic error (Issue 1460)#1471leahpeker wants to merge 2 commits into
leahpeker wants to merge 2 commits into
Conversation
get_survey_public no longer filters on is_active, so a closed survey resolves and returns is_active=false rather than 404ing into a generic "couldn't load" error. The members-only visibility gate still 404s for anonymous callers. Submitting to a closed survey is rejected with a new survey.closed code (400). SurveyScreen renders a closed state for an inactive survey, guarded on pollResult being null so a finalized datetime poll keeps its existing finalized view (finalize_poll also sets is_active=False).
…ed gate The finalized-poll path is newly reachable: before the is_active filter was dropped, get_survey_public 404'd every finalized poll, so the readonly finalized branch was dead code on that route. - GET a finalized poll returns 200 with its poll_result - submitting to a finalized poll is rejected with survey.closed - the anonymous 404 on a closed members-only survey leaks no title, description or question label - a submit rejected with survey.closed invalidates the survey query
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.
Summary
get_survey_publicno longer filters onis_active, so a closed survey resolves and returnsis_active: falseinstead of 404ing into the generic "couldn't load the survey — try refreshing" error. The members-only visibility gate is unchanged — those still 404 for anonymous callers.submit_survey_responserejects a closed survey with a newsurvey.closedcode (400) rather than a bare 404, mapped in the frontend to "this survey is closed — responses are no longer accepted".SurveyScreenrenders a closed state (title, description, status message, no form or submit button) whenisActiveis false. Guarded onpollResult === nullso a finalized datetime poll keeps its existing finalized view —finalize_pollalso setsis_active = False, so without that guard finalized polls would have regressed into the closed state.make dump-codes+make generate-codes;make agent-check-codesconfirmsvalidation_codes.json,validationCodes.gen.ts, andopenapi_schema.jsonare all up to date.Closes #1460
Test plan
backend/tests/test_surveys_public.py::TestClosedSurvey— closed survey returns 200 withis_active: false; closed members-only survey 404s for anonymous and 200s for a member; submit to a closed survey returns 400survey.closedand writes no response; submit to a closed members-only survey 404s for anonymous.frontend/src/screens/surveys/SurveyScreen.test.tsx— closed render (no form/submit), active survey still renders the form, and an inactive survey with a poll result keeps the finalized view.CI note
make agent-cipasses except for 7 pre-existing failures unrelated to this change:tests/test_sse.py(5, needspg_notify),tests/test_poll_finalize_race.py, andtests/test_rsvp_capacity_race.py(need real row locking). These fail locally because the agent targets run against per-worktree SQLite; the Makefile documents this above itsifdef CIblock, and GitHub Actions runs them against Postgres. Baseline before this change was identical (7 failed / 2213 passed). Frontend CI, lint, typecheck, complexity and check-codes are all green.🤖 Generated with Claude Code