Skip to content

fix(report): allow community_watch_* reasons in DB check constraint#4844

Merged
mashbean merged 1 commit into
developfrom
fix/report-reason-db-constraint
Jun 13, 2026
Merged

fix(report): allow community_watch_* reasons in DB check constraint#4844
mashbean merged 1 commit into
developfrom
fix/report-reason-db-constraint

Conversation

@mashbean

Copy link
Copy Markdown
Contributor

Problem

The GraphQL ReportReason enum (src/types/system.ts) declares community_watch_porn_ad and community_watch_spam_ad, but the report.reason DB check constraint (report_reason_check, from 20231221154057_alter_report_add_reason) only allows the original five values. submitReport inserts the raw reason, so any report submitted with either community_watch value fails in production:

new row for relation "report" violates check constraint "report_reason_check"
(INTERNAL_SERVER_ERROR)

Surfaced live by the coastguard bot's Tier-1 reports (it sent community_watch_porn_ad and every insert was rejected).

Fix

Migration realigns the DB check constraint with the schema — adds the two community_watch values. The enum is the contract; the constraint had drifted.

communityWatchRemoveComment is unaffected: it syncs illegal_advertising (not these values) into the report table.

Notes / follow-up

  • The OSS reports view (src/queries/system/oss/reports.ts) filters reason = 'illegal_advertising'; community_watch_* reports won't appear there. If those should surface in that view, that's a separate product decision.
  • Alternative considered: map community_watch_* → illegal_advertising in the submitReport resolver, or drop them from the submittable enum. Chose the migration since the enum already advertises them as valid ReportReason values with doc comments — the DB was simply stale.

Test plan

  • Run migration on staging; submitReport with community_watch_porn_ad/community_watch_spam_ad succeeds
  • communityWatchRemoveComment still works (illegal_advertising)
  • down migration restores the original five-value constraint

🤖 Generated with Claude Code

The GraphQL ReportReason enum declares community_watch_porn_ad and
community_watch_spam_ad, but report_reason_check (from 20231221154057) was never
updated to permit them. submitReport inserts the raw reason, so any report with
those values failed in production with a report_reason_check violation
(INTERNAL_SERVER_ERROR) — surfaced by the coastguard bot's Tier-1 reports.

Realign the DB constraint with the schema. communityWatchRemoveComment is
unaffected (it syncs illegal_advertising, not these values).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mashbean mashbean requested a review from a team as a code owner June 13, 2026 03:44
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.03%. Comparing base (85bdbe1) to head (fd62323).
⚠️ Report is 33 commits behind head on develop.

Files with missing lines Patch % Lines
...3000000_alter_report_reason_add_community_watch.js 80.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4844      +/-   ##
===========================================
+ Coverage    72.82%   73.03%   +0.21%     
===========================================
  Files         1054     1066      +12     
  Lines        21263    21638     +375     
  Branches      4671     4808     +137     
===========================================
+ Hits         15485    15804     +319     
+ Misses        5706     5354     -352     
- Partials        72      480     +408     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mashbean mashbean merged commit 9297f35 into develop Jun 13, 2026
5 checks passed
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