fix(organization): preserve existing metadata when updating organization description - #6487
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(organization): preserve existing metadata when updating organization description#6487pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source
Inspecting the organization tools cleanup area, found that
ORGANIZATION_UPDATEoverwrites the entire organization metadata object instead of merging the new description field into it. This causes other metadata fields (e.g.,archived,archivedAt) to be silently lost when updating just the description.Impact
When calling
ORGANIZATION_UPDATEwith a new description on an organization that already has metadata, all existing metadata fields exceptdescriptionare dropped from the metadata object. This can cause data loss of any fields stored in organization metadata.Solution
Fetch the existing organization metadata before updating, then merge the new description field into it instead of replacing the entire object. This ensures all existing metadata fields are preserved.
Regression Test
Added test
merges description into existing metadata instead of replacing itthat verifies:{ archived: true, archivedAt: "..." })ORGANIZATION_UPDATEis called with a new descriptionarchivedandarchivedAtfieldsdescriptionfieldVerification
bun test apps/api/src/tools/organization/update.test.ts— all 3 tests pass (2 existing + 1 regression)bunx tsc --noEmitin apps/api — no type errorsbun run fmt— no formatting changes neededLine Delta
-3 / +58 in two files (update.ts: core fix, update.test.ts: regression test + test setup)
Summary by cubic
Preserves existing organization metadata when updating the description to prevent data loss. Previously, ORGANIZATION_UPDATE replaced metadata with { description }, dropping fields like archived and archivedAt; now it merges description into existing metadata.
Written for commit 8f81be8. Summary will update on new commits.