[PR #1319] [MERGED] fix: broken endpoint to update a field in a document #1554

Closed
opened 2026-02-26 19:33:45 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1319
Author: @Etrenak
Created: 9/2/2024
Status: Merged
Merged: 9/5/2024
Merged by: @Mythie

Base: mainHead: fix/1318-update-fields


📝 Commits (1)

  • 253cb1c fix: broken endpoint to update a field in a document

📊 Changes

2 files changed (+35 additions, -28 deletions)

View changed files

📝 packages/api/v1/implementation.ts (+3 -1)
📝 packages/lib/server-only/field/update-field.ts (+32 -27)

📄 Description

Description

Fixes #1318 and allows to submit a partial fieldMeta when updating a field instead of replacing the current fieldMeta, to be consistent with other endpoints.

Fixes #1318

Changes Made

  • Moved some variables higher in the code because they were referenced by code above it, causing the Unauthorized response.
  • Actually provided the fieldMeta object from the endpoint implementation to the updateField function so it can update the database.

Testing Performed

I tested to patch a field with the following payload:

{
  "recipientId": 3,
  "fieldMeta": {
    "text": "my super text"
  }
}

And I observed in the GUI that the text has changed.
Then I tested to patch the exact same field with this payload :

{
  "recipientId": 3,
  "fieldMeta": {
    "label": "my super label"
  }
}

And I was able to confirm in the GUI that the text was still my super text and the label had been updated to my super label

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Summary by CodeRabbit

  • New Features

    • Enhanced the updateField functionality to accept additional metadata, allowing for more complex data updates.
    • Improved handling of field metadata by merging old and new values during updates.
  • Bug Fixes

    • Optimized user and team data retrieval by moving it inside the transaction block, ensuring data integrity during field updates.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1319 **Author:** [@Etrenak](https://github.com/Etrenak) **Created:** 9/2/2024 **Status:** ✅ Merged **Merged:** 9/5/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/1318-update-fields` --- ### 📝 Commits (1) - [`253cb1c`](https://github.com/documenso/documenso/commit/253cb1c7fcefc5b1afe9391decb97e18c6594595) fix: broken endpoint to update a field in a document ### 📊 Changes **2 files changed** (+35 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/api/v1/implementation.ts` (+3 -1) 📝 `packages/lib/server-only/field/update-field.ts` (+32 -27) </details> ### 📄 Description ## Description Fixes #1318 and allows to submit a partial `fieldMeta` when updating a field instead of replacing the current `fieldMeta`, to be consistent with other endpoints. ## Related Issue Fixes #1318 ## Changes Made - Moved some variables higher in the code because they were referenced by code above it, causing the Unauthorized response. - Actually provided the `fieldMeta` object from the endpoint implementation to the `updateField` function so it can update the database. ## Testing Performed I tested to patch a field with the following payload: ``` { "recipientId": 3, "fieldMeta": { "text": "my super text" } } ``` And I observed in the GUI that the text has changed. Then I tested to patch the exact same field with this payload : ``` { "recipientId": 3, "fieldMeta": { "label": "my super label" } } ``` And I was able to confirm in the GUI that the text was still `my super text` and the label had been updated to `my super label` ## Checklist - [x] I have tested these changes locally and they work as expected. - [ ] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [x] I have followed the project's coding style guidelines. - [ ] I have addressed the code review feedback from the previous submission, if applicable. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced the `updateField` functionality to accept additional metadata, allowing for more complex data updates. - Improved handling of field metadata by merging old and new values during updates. - **Bug Fixes** - Optimized user and team data retrieval by moving it inside the transaction block, ensuring data integrity during field updates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:45 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1554
No description provided.