Repository navigation
Constrain trade inquiry venueType to known options server-side (#126) - #127
Merged
Merged
Conversation
Reviewer's GuideThe PR makes business type validation consistent across the UI and server by sharing a canonical option list, rejecting arbitrary API values before side effects, and adding focused regression tests; it also updates notification wording and includes temporary production audit scripts. Sequence diagram for server-side trade inquiry venue validationsequenceDiagram
participant Client
participant API as handleTradeInquiry
participant Submit as trade lead submit
participant Email as Notification email
Client->>API: POST /api/trade-inquiry
API->>API: Validate required fields, length, and email
API->>API: Trim venueType
alt venueType not in TRADE_VENUE_TYPES
API-->>Client: 400 Please choose a business type.
Note over API,Submit: submit is not called
else canonical venueType
API->>Submit: submit(trade lead)
Submit->>Email: Send Business Type notification
API-->>Client: Success response
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The form select only offers the six canonical business types, but the API accepted any free-text value — a direct request could persist arbitrary venueType strings into tradeLeads and the notification email. The server now enforces the shared TRADE_VENUE_TYPES list with a 400 before persistence, same pattern as the email-format check, and the form renders options from that list so the two can never drift. Also aligns the internal notification email row label with the current "Business type" form/doc terminology. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
spizeck
force-pushed
the
fix/issue-126-venue-type-validation
branch
from
September 24, 2026 01:16
fd6b15f to
6394ca4
Compare
This branch was successfully deployed
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
Post-professionalization audit finding (also flagged during #117):
POST /api/trade-inquiryrequiredvenueTypeto be present and ≤64 chars but accepted any string. A direct request could persist arbitrary values intotradeLeadsand the Resend notification email. The form's<select>only offers six canonical options — the server now enforces the same set.Closes #126
Changes
lib/trade-leads-common.ts: new exportedTRADE_VENUE_TYPES(value/label pairs — single source for the<select>and the API check); pipeline rejects unknownvenueTypewith400 { ok: false, error: "Please choose a business type." }after required/length/email validation, before honeypot/rate-limit/submit. Trimmed values are checked, matching existing normalization.components/trade-inquiry-form.tsx: renders options fromTRADE_VENUE_TYPESinstead of a local array (module is dependency-free, safe for the client bundle).lib/trade-leads.ts: internal notification email row labelVenue Type→Business Type, matching the current form/admin-doc terminology.tests/lib/trade-leads.test.ts: rejectsgarbage/Bar/bar; DROP TABLE/barswith 400 +submitnever called; accepts all six canonical values and a whitespace-padded value (trim normalization).Regression proof: with the check removed,
venueType: "garbage"returned 200 and reachedsubmit; restored → 400, submit never called.Verification
npx tsc --noEmit— cleannpm run lint— clean (pre-existing jsx-ast-utils notice)npm test— 352 pass (2 new tests)npm run build— passnpx playwright teston trade-touching specs (smoke/accessibility/analytics) — 42 passnpm run test:rules— 29 pass (ran on identical pipeline earlier today; no rules-adjacent change)npm run check:md-links,check:react-versions— passnpm audit --omit=dev— 0 vulnerabilitiesRisk / deployment notes
Direct API callers sending non-canonical
venueTypevalues (e.g. capitalized"Bar") now get 400 — that is the intended fix; the UI only ever submits canonical lowercase values. No schema change; existing records unaffected.Generated with Devin
Summary by Sourcery
Constrain trade inquiry business types to the canonical options accepted by the form.
Bug Fixes:
Enhancements:
Tests: