Skip to content

Add strict request validation for POST /v1/access/check #260

Description

@Lakes41

Difficulty: Intermediate
Type: bug

Background
POST /v1/access/check takes { wallet, communityId, resource } and returns an allow/deny decision — this is the core access-decision endpoint feeding the policy engine.

Problem
Without strict schema validation, malformed input (invalid wallet format, missing communityId, unexpected resource shapes) can reach the policy engine and produce ambiguous or misleading decisions instead of a clear 400 error.

Expected outcome
The route validates wallet (checksummed/lowercased EVM address format), communityId (valid UUID/ID format matching the schema), and resource against a strict schema before reaching the policy engine, returning descriptive 400 errors on failure.

Suggested implementation

  • Add a Zod (or Fastify JSON-schema) validator for the request body in the access-check route.
  • Normalize wallet addresses (lowercase or checksum) before querying, consistent with how they're stored via Prisma.
  • Add explicit error messages per invalid field (not a generic "bad request").
  • Add unit tests covering missing fields, malformed wallet, and unknown communityId.

Acceptance criteria

  • Invalid wallet format returns 400 with a clear message
  • Missing communityId or resource returns 400
  • Valid requests behave exactly as before
  • OpenAPI spec regenerated and committed

Likely affected files/directories

  • apps/access-api/src/routes/ (access/check route)
  • packages/shared-types/
  • docs/openapi.json

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsbugConfirmed defect or incorrect behavior that needs to be fixedintermediateIntermediate difficulty tasks requiring solid experience and some context

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions