fix(agent-toolkit): write a numeric assetId in finalize_asset_upload - #492
Open
marcin-polak-monday wants to merge 2 commits into
Open
marcin-polak-monday wants to merge 2 commits into
marcin-polak-monday wants to merge 2 commits into
Conversation
`finalize_asset_upload` wrote `assetId` into the file column as a string. The monolith compares that value against the asset's numeric id when it decides whether a file column grants a guest access to a file, and a string never matches, so guests on boards with permission rules saw "File not found or deleted" for every file uploaded through this tool. Members and admins skip that check and were unaffected. `complete_upload.id` is a GraphQL `ID`, serialized as a string, so coerce it with `Number()` before writing `assetId` and when returning `asset_id`. Send `isImage` as well so image uploads get a thumbnail in the cell, the same shape the web uploader writes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
Monday.com item
https://monday.monday.com/boards/8297269624/pulses/12889382164
Summary
Guests could not open files uploaded to a file column through
finalize_asset_upload, while members and admins could open the same files. The tool wrote the file column value withassetId: String(asset.id). The web uploader writes an integer. When a non-member guest opens a file on a board with permission rules, the monolith (AssetService.find_files_column_value_by_asset) scans the item's file column values withfile["assetId"] == asset.id. Ruby does not coerce across types, so"3241543667" == 3241543667is false, the asset is treated as not present in any visible column, andassets_by_idsreturns an empty result. The UI then shows "File not found or deleted". Members and admins never reach that comparison becauseboard.member?short-circuits first.complete_upload.idis a GraphQLID, which the API serializes as a string even though the underlying id is numeric. The tool now coerces it withNumber()before writingassetId, and returnsasset_idas a number as well.isImageis now sent too, matching the shape the web uploader writes, so image uploads render a thumbnail in the cell.Reproduced end to end on a production scratch board: an upload through this tool stored
"assetId":"3241543667"while every UI upload on the same board stored an integer. Full investigation is on the linked item.Changes
finalize-asset-upload-tool.ts:assetId: Number(asset.id),asset_id: Number(asset.id),isImagederived fromcontent_type,CompleteUploadMutation.idtyped asstring.finalize-asset-upload-tool.test.ts: mock asset id is now a string so the coercion is exercised, plus tests for the numericassetIdand forisImageon image uploads.CHANGELOG.mdandpackage.json: 5.70.3.Not changed
column_idis still not passed tocomplete_upload. Passing it makes assets-core attach the file itself whenassets-core-asset-created-event-instead-of-frontendis on for the account, which would duplicate the entry this tool writes. Left for a follow-up once the tool can skip its ownchange_column_valuein that case.assetIdare not repaired by this change. They need re-uploading, or a monolith-side tolerant comparison.Testing
yarn jest finalize-asset-upload-tool: 6 passed.eslintandprettier --checkclean on both files.🤖 Generated with Claude Code