Skip to content

fix: omit language from non-public form 403 - #264

Merged
rkorszun merged 1 commit into
developfrom
cursor/public-form-403-language-29d4
Oct 13, 2026
Merged

rkorszun merged 1 commit into
developfrom
cursor/public-form-403-language-29d4

Conversation

@rkorszun

Copy link
Copy Markdown
Collaborator

Fixes #259

Summary

GET /api/public/forms/:id no longer returns the creator-chosen language on 403 for a non-public form. That field was a small metadata leak after #250.

The respondent UI still localizes the closed/error message: it uses language when the API sends it (public-but-inactive 403), otherwise it maps the browser locale (pl-PL → pl, en-GB → en-US) and falls back to en-US.

Root cause

FormsService.findPublicForm threw ForbiddenException({ message, language }) for !form.isPublic, so Nest serialized language on an unauthenticated 403.

Fix

  • Non-public 403: generic ForbiddenException('This form is not public') — no language.
  • Public-but-inactive 403: still includes language (the form was already public).
  • Client: detectBrowserLanguage() for 403/404/load errors when the body has no language.

Tests

  • Server unit: non-public 403 has no language; inactive public 403 still has it.
  • Client: browser locale mapping; generic 403 with navigator.language = pl-PL shows Polish formClosed.
  • E2E: non-public GET returns 403 without language.

Local results

Check Result
pnpm --filter server test 53 suites, 292 passed, 1 skipped
pnpm --filter client test 9 files, 49 passed
pnpm --filter client exec tsc --noEmit passed

Do not merge. Draft until CI is green.

Open in Web Open in Cursor 

GET /api/public/forms/:id no longer returns the creator-chosen language
on 403 for a non-public form. The respondent UI falls back to the
browser locale or en-US.

Fixes #259

Co-authored-by: Rafal Korszun <rkorszun@users.noreply.github.com>
@rkorszun
rkorszun marked this pull request as ready for review October 13, 2026 06:57
@rkorszun
rkorszun merged commit 44b904e into develop Oct 13, 2026
4 checks passed
@rkorszun
rkorszun deleted the cursor/public-form-403-language-29d4 branch October 13, 2026 06:57
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.

Public form 403 (non-public form) returns language

2 participants