Skip to content

feat(backend): add PATCH /api/bounties/:id for maintainer-editable fields (#770) - #1098

Open
Abba073 wants to merge 2 commits into
ritik4ever:mainfrom
Abba073:feat/patch-bounty-fields-770
Open

Abba073 wants to merge 2 commits into
ritik4ever:mainfrom
Abba073:feat/patch-bounty-fields-770

Conversation

@Abba073

@Abba073 Abba073 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Implements issue #770 — a generic PATCH endpoint for maintainer-editable bounty fields.

Changes

backend/src/validation/schemas.ts

  • Added patchBountySchema with Zod validation for title, description, labels, deadline
  • Uses .passthrough() + superRefine to explicitly reject immutable fields (amount, status, contributor, tokenSymbol, repo, issueNumber) with a clear validation error per field
  • Requires at least one patchable field to be provided
  • Added patch_fields to bountyAuditLogSchema transition enum

backend/src/services/bountyStore.ts

  • Added patch_fields to BountyTransitionType
  • Added patchBountyFields() store function with file lock, maintainer ownership check, field diffing, and no-op detection
  • Emits a patch_fields audit-log entry with field_from / field_to metadata for each changed field

backend/src/app.ts

  • Added PATCH /api/bounties/:id route with mutationLimiter, requireJsonContentType, createStellarSignatureAuthMiddleware, validateBody(patchBountySchema)

backend/test/api.patchBounty.test.ts (new)

  • 19 tests — all passing

Acceptance Criteria

  • A maintainer can PATCH allowed fields on their own bounty successfully
  • Attempting to PATCH an immutable field (e.g. amount) is rejected with a validation error
  • A non-owning maintainer cannot PATCH another maintainer's bounty

Closes #770

…elds (ritik4ever#770)

- Add PATCH /api/bounties/:id endpoint accepting title, description, labels, deadline
- Validate with patchBountySchema (Zod) using .passthrough() + superRefine to
  explicitly reject immutable fields (amount, status, contributor, tokenSymbol,
  repo, issueNumber) with a clear validation error
- Require maintainer auth via createStellarSignatureAuthMiddleware
- Emit a patch_fields audit-log entry with a full field diff (field_from / field_to)
- Add patch_fields to BountyTransitionType in bountyStore.ts
- Add patchBountyFields() store function with withStoreLock, diff detection,
  and cache invalidation
- Add patch_fields to bountyAuditLogSchema transition enum
- Add 19 tests in api.patchBounty.test.ts covering:
  - Happy-path patches (title, description, labels, deadline, multi-field, no-op)
  - Audit log diff recording
  - Authorization rejection for non-owning maintainers
  - Immutable field rejection (amount, status, contributor)
  - Validation edge cases (no fields, too short, too many labels, past deadline,
    unknown ID, missing Content-Type)

Closes ritik4ever#770
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Abba073 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Abba073 is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add generic PATCH endpoint for maintainer-editable bounty fields

1 participant