Skip to content

Fix input validation and meta type alignment in apps/me API routes#178

Closed
Copilot wants to merge 2 commits intofeat/mefrom
copilot/sub-pr-163-again
Closed

Fix input validation and meta type alignment in apps/me API routes#178
Copilot wants to merge 2 commits intofeat/mefrom
copilot/sub-pr-163-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

Falsy checks on numeric IDs silently rejected 0 as invalid, and formData.get("file") was cast without a type guard. UserUpsert.meta was typed as string despite the DB column being a JSON type.

Changes

  • roles/route.ts & positions/route.ts: Replace !body.orgId / !body.positionId falsy checks with explicit == null + typeof === "number" guards:

    // before
    if (!body.orgId || !body.positionId) { ... }
    
    // after
    if (body.orgId == null || typeof body.orgId !== "number" ||
        body.positionId == null || typeof body.positionId !== "number") { ... }
  • avatar/route.ts: Replace unsafe as File | null cast with an instanceof File runtime guard — a string value from formData.get() now returns a 400 before any file methods are called. Also corrects the stale error message that listed gif as an allowed type.

  • types.ts: Change UserUpsert.meta from string to Record<string, unknown> to match the DB JSON column (json().$type<UserMeta>()) and eliminate the type mismatch throughout the app.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: taterhead247 <26818765+taterhead247@users.noreply.github.com>
Copilot AI changed the title [WIP] Add initial setup for F3 Me profile manager app Fix input validation and meta type alignment in apps/me API routes Mar 13, 2026
Copilot AI requested a review from taterhead247 March 13, 2026 14:06
@taterhead247 taterhead247 deleted the copilot/sub-pr-163-again branch March 13, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

2 participants