Skip to content

fix(api): keep each grant approval's own amount - #1537

Open
Code-Parth wants to merge 5 commits into
SuperteamDAO:mainfrom
Code-Parth:split/fix-grant-approval-amounts
Open

Code-Parth wants to merge 5 commits into
SuperteamDAO:mainfrom
Code-Parth:split/fix-grant-approval-amounts

Conversation

@Code-Parth

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes grant approvals storing one application's amount on another when several are approved at once. There were two causes in src/pages/api/sponsor-dashboard/grants/update-application-status.ts:

  1. Updates were pushed into an array after awaiting token prices, so the array order depended on which price lookup finished first, and the transaction matched updates to applications by index. Updates are now returned from Promise.all together with their application id.
  2. Approved amounts were read from the request with data[k], assuming findMany({ id: { in } }) returns rows in request order. MySQL does not guarantee that. Amounts are now looked up by application id.

applicationStatus is also validated against the Prisma enum, so an invalid status returns 400 instead of failing inside the transaction.

Where should the reviewer start?

src/pages/api/sponsor-dashboard/grants/update-application-status.ts, the approvedAmountById map and the updates array.

How should this be manually tested?

  • Select two or more pending grant applications, give each a different amount, and approve them together. Each keeps its own amount, in USD and tranche count too.
  • Add a custom note while approving several. The email preview validation still runs per application.
  • Send applicationStatus: "Foo" to the endpoint. It returns 400.

Any background context you want to provide?

Also removes the last two explicit any in the API routes.

What are the relevant issues?

None.

Screenshots (if appropriate)

None.

🤖 Generated with Claude Code

Code-Parth and others added 5 commits November 20, 2026 17:02
Adds getErrorMessage, jsonResponse, parseQuestionAnswers,
parseQuestionConfigs, getPaymentAmount and the skills and linkedTwitter
parsers, and types the shared server utils against the Prisma models
instead of any. No call sites in API routes change here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catch clauses are unknown and narrowed, request bodies and JSON columns
are parsed instead of cast. The OG image routes fall back to "?" when the
name param is missing, and scout generation keeps existing scouts and
returns early when the bounty has no matchable skills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers every route under src/pages/api except the sponsor dashboard.
catch clauses are unknown and narrowed, and request bodies, sessions and
JSON columns use the Prisma models and route selects instead of casts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catch clauses are unknown and narrowed, and listing rewards, payment
details and export rows use typed shapes instead of any. Payment history
stored in an unexpected shape is now refused with an error instead of
being treated as empty and overwritten on the next payment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Approving several applications at once could store one application's
amount on another. Updates were pushed after awaiting token prices, so
array order did not match the applications, and amounts were read from
the request by index even though findMany with `in` does not return rows
in request order. Updates are now returned from Promise.all and amounts
are matched by application id.

applicationStatus is validated against the Prisma enum, so an invalid
status returns 400 instead of failing inside the transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@Code-Parth is attempting to deploy a commit to the Superteam Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 157 files, which is 57 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

CodeRabbit couldn't verify your organization's usage billing state, so no usage-priced review was started. Retry after the billing service recovers.

Check out review usage here.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c533577-f15b-42c0-91a2-106eeb5f4ccd
Commits

Reviewing files that changed from the base of the PR and between 7faae49 and 9fe6b94.

Files selected for processing: 157

  • src/app/api/dynamic-og/category/route.tsx
  • src/app/api/dynamic-og/grant/route.tsx
  • src/app/api/dynamic-og/listing/route.tsx
  • src/app/api/dynamic-og/pro-talent/route.tsx
  • src/app/api/dynamic-og/pro-x/route.tsx
  • src/app/api/dynamic-og/region/route.tsx
  • src/app/api/dynamic-og/skill/route.tsx
  • src/app/api/dynamic-og/sponsor/route.tsx
  • src/app/api/dynamic-og/talent/route.tsx
  • src/app/api/dynamic-og/winners/route.tsx
  • src/app/api/grant-application/create/route.ts
  • src/app/api/grant-application/request-tranche/route.ts
  • src/app/api/grant-application/update/route.ts
  • src/app/api/homepage/feed/route.ts
  • src/app/api/homepage/recent-earners/route.ts
  • src/app/api/homepage/sponsor-count/route.ts
  • src/app/api/homepage/stats/route.ts
  • src/app/api/homepage/user-count/route.ts
  • src/app/api/sponsor-dashboard/ai-generate/questions/route.ts
  • src/app/api/sponsor-dashboard/ai-generate/rewards/route.ts
  • src/app/api/sponsor-dashboard/ai-generate/skills/route.ts
  • src/app/api/sponsor-dashboard/ai-generate/title/route.ts
  • src/app/api/sponsor-dashboard/ai-generate/token/route.ts
  • src/app/api/sponsor-dashboard/grant-application/ai/commit-reviewed/route.ts
  • src/app/api/sponsor-dashboard/grant-application/ai/unreviewed/route.ts
  • src/app/api/sponsor-dashboard/grants/update-tranche-status/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/announce/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/delete/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/publish/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/scout/invite/[userId]/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/scout/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/unpublish/route.ts
  • src/app/api/sponsor-dashboard/listing/[id]/update/route.ts
  • src/app/api/sponsor-dashboard/listing/check-slug/route.ts
  • src/app/api/sponsor-dashboard/submissions/ai/commit-reviewed/route.ts
  • src/app/api/sponsor-dashboard/submissions/ai/unreviewed/route.ts
  • src/app/api/sponsor-dashboard/templates/[slug]/route.ts
  • src/app/api/sponsor-dashboard/templates/route.ts
  • src/app/api/user/complete-profile/route.ts
  • src/app/api/user/credit/balance/route.ts
  • src/app/api/user/credit/history/route.ts
  • src/features/feed/constants/homeFeed.ts
  • src/features/grants/utils/grantApplicationSchema.ts
  • src/features/listings/utils/paymentDetails.ts
  • src/features/listings/utils/submissionFormSchema.ts
  • src/features/social/utils/linkedTwitter.ts
  • src/interface/next-auth.d.ts
  • src/interface/skills.ts
  • src/lib/api.ts
  • src/lib/image-upload/cloudinary-client.ts
  • src/lib/image-upload/errors.ts
  • src/lib/rateLimiterService.ts
  • src/pages/api/agents/claim.ts
  • src/pages/api/agents/comments/[id].ts
  • src/pages/api/agents/comments/create.ts
  • src/pages/api/agents/index.ts
  • src/pages/api/agents/submissions/create.ts
  • src/pages/api/agents/submissions/update.ts
  • src/pages/api/auth/[...nextauth].ts
  • src/pages/api/comment/[id]/delete.ts
  • src/pages/api/comment/[id]/index.ts
  • src/pages/api/comment/[id]/pin.ts
  • src/pages/api/comment/create.ts
  • src/pages/api/email/manual/welcome-sponsor.ts
  • src/pages/api/feed/[type]/[id]/get.ts
  • src/pages/api/feed/get.ts
  • src/pages/api/grant-application/get.ts
  • src/pages/api/grant-application/like.ts
  • src/pages/api/grants/[slug].ts
  • src/pages/api/grants/delete/[id].ts
  • src/pages/api/grants/live.ts
  • src/pages/api/grants/update/[id].ts
  • src/pages/api/hackathon/subscribe/get.ts
  • src/pages/api/hackathon/subscribe/toggle.ts
  • src/pages/api/listings/[listingId]/submission-count.ts
  • src/pages/api/listings/[listingId]/winners.ts
  • src/pages/api/listings/bookmarks.ts
  • src/pages/api/listings/details/[slug].ts
  • src/pages/api/listings/latest-active-slug.ts
  • src/pages/api/listings/submissions/[slug].ts
  • src/pages/api/member-invites/accept.ts
  • src/pages/api/member-invites/send.ts
  • src/pages/api/pow/create.ts
  • src/pages/api/pow/edit.ts
  • src/pages/api/pow/get.ts
  • src/pages/api/pow/like.ts
  • src/pages/api/search/[query].ts
  • src/pages/api/sponsor-dashboard/[slug]/listing.ts
  • src/pages/api/sponsor-dashboard/[slug]/submissions.ts
  • src/pages/api/sponsor-dashboard/active-hackathons.ts
  • src/pages/api/sponsor-dashboard/application/export-sheets.ts
  • src/pages/api/sponsor-dashboard/application/export.ts
  • src/pages/api/sponsor-dashboard/grants/[slug]/applications.ts
  • src/pages/api/sponsor-dashboard/grants/[slug]/index.ts
  • src/pages/api/sponsor-dashboard/grants/[slug]/tranches.ts
  • src/pages/api/sponsor-dashboard/grants/add-tranche.ts
  • src/pages/api/sponsor-dashboard/grants/approved-grantees.ts
  • src/pages/api/sponsor-dashboard/grants/update-application-status.ts
  • src/pages/api/sponsor-dashboard/grants/update-label.ts
  • src/pages/api/sponsor-dashboard/grants/update-notes.ts
  • src/pages/api/sponsor-dashboard/grants/update-ship-progress.ts
  • src/pages/api/sponsor-dashboard/listings/index.ts
  • src/pages/api/sponsor-dashboard/listings/is-create-allowed.ts
  • src/pages/api/sponsor-dashboard/listings/verify-external-payment.ts
  • src/pages/api/sponsor-dashboard/local-talent/export.ts
  • src/pages/api/sponsor-dashboard/local-talent/index.ts
  • src/pages/api/sponsor-dashboard/members/index.ts
  • src/pages/api/sponsor-dashboard/members/remove.ts
  • src/pages/api/sponsor-dashboard/members/update-role.ts
  • src/pages/api/sponsor-dashboard/submission/add-payment.ts
  • src/pages/api/sponsor-dashboard/submission/export-sheets.ts
  • src/pages/api/sponsor-dashboard/submission/export.ts
  • src/pages/api/sponsor-dashboard/submission/reject.ts
  • src/pages/api/sponsor-dashboard/submission/toggle-winner.ts
  • src/pages/api/sponsor-dashboard/submission/update-label.ts
  • src/pages/api/sponsor-dashboard/submission/update-notes.ts
  • src/pages/api/sponsor/verification.ts
  • src/pages/api/sponsors/check-name.ts
  • src/pages/api/sponsors/check-slug.ts
  • src/pages/api/sponsors/create.ts
  • src/pages/api/sponsors/edit.ts
  • src/pages/api/sponsors/index.ts
  • src/pages/api/sponsors/list.ts
  • src/pages/api/sponsors/stats.ts
  • src/pages/api/sponsors/update-entity-name.ts
  • src/pages/api/sponsors/usersponsor-details.ts
  • src/pages/api/submission/check.ts
  • src/pages/api/submission/create.ts
  • src/pages/api/submission/get.ts
  • src/pages/api/submission/like.ts
  • src/pages/api/submission/update.ts
  • src/pages/api/twitter/tweet-stats.ts
  • src/pages/api/user/create.ts
  • src/pages/api/user/edit.ts
  • src/pages/api/user/pfps.ts
  • src/pages/api/user/random-username.ts
  • src/pages/api/user/referral/verify.ts
  • src/pages/api/user/resolve-privy-dids.ts
  • src/pages/api/user/search.ts
  • src/pages/api/user/update-email-settings.ts
  • src/pages/api/user/update-survey.ts
  • src/pages/api/user/update.ts
  • src/pages/api/user/username.ts
  • src/prisma.ts
  • src/utils/airtable.ts
  • src/utils/atoms.ts
  • src/utils/cloudinary.ts
  • src/utils/filterAllowedFields.ts
  • src/utils/getErrorMessage.ts
  • src/utils/jsonResponse.ts
  • src/utils/ogHelpers.ts
  • src/utils/parseQuestionAnswers.ts
  • src/utils/parseQuestionConfigs.ts
  • src/utils/safeStringify.ts
  • src/utils/solanaTransactionHelpers.ts
  • src/utils/truncatePublicKey.ts
  • src/utils/undefinedToNull.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Code-Parth

Copy link
Copy Markdown
Contributor Author

Merge order: 5 of 8. Please merge after #1536; until then this diff also shows the earlier PRs' files. Next is #1538.

This branch has not been deployed

No deployments
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