Fix hash ID decoding in playlist contents and grant request bodies#757
Merged
rickyrombo merged 4 commits intomainfrom Apr 8, 2026
Merged
Fix hash ID decoding in playlist contents and grant request bodies#757rickyrombo merged 4 commits intomainfrom
rickyrombo merged 4 commits intomainfrom
Conversation
- Add trashid.IntId type: decodes hash IDs on input, marshals as plain int — for chain metadata where the indexer expects numeric IDs - PlaylistTrackInfo.TrackId: string → trashid.IntId so playlist_contents track IDs are decoded at the API boundary instead of forwarded raw - addManagerBody.ManagerUserId: string → trashid.HashId (removes manual DecodeHashId call) - approveGrantBody.GrantorUserId: string → trashid.HashId (removes manual DecodeHashId call) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates API request decoding so hash IDs are converted at the API boundary for playlist contents and grant-related request bodies, ensuring downstream chain/indexer metadata uses the expected numeric IDs.
Changes:
- Introduces
trashid.IntIdto accept either hash IDs or raw integers on JSON input, while always marshaling as a JSON number. - Updates playlist
playlist_contents[].track_idto usetrashid.IntIdso track IDs are emitted as integers in chain metadata. - Switches
manager_user_id/grantor_user_idrequest fields totrashid.HashId, removing redundant manual decode calls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
trashid/hashid.go |
Adds IntId JSON (un)marshal behavior to normalize IDs to integers for chain metadata. |
api/v1_playlist.go |
Changes playlist contents track IDs to trashid.IntId so metadata contains numeric track_ids. |
api/v1_grants.go |
Changes grant request bodies to typed hash IDs and removes manual decoding logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AudiusProject/api/sessions/1e868cb7-009d-437d-a60f-b0b1a123b27c Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
Copilot
AI
changed the title
Fix hash ID decoding in playlist contents and grant request bodies
Add unit tests for trashid.IntId
Apr 8, 2026
Addresses PR feedback: adds validate:"required,min=1" struct tags to ManagerUserId and GrantorUserId, and wires up requestValidator.Validate calls so zero/missing values are rejected before hitting the DB or chain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
trashid.IntIdtype: accepts hash IDs or raw ints on JSON input, always marshals as a plain integer. Designed for chain metadata fields where the indexer expects numeric IDs.PlaylistTrackInfo.TrackId(string→trashid.IntId): playlist_contents track IDs are now decoded at the API boundary. Previously hash ID strings were forwarded raw to chain, requiring an indexer workaround.addManagerBody.ManagerUserId(string→trashid.HashId): removes redundant manualDecodeHashIdcall, adds struct tag validationapproveGrantBody.GrantorUserId(string→trashid.HashId): removes redundant manualDecodeHashIdcall, adds struct tag validationTest plan
trashid.IntIdmarshal/unmarshal round-trip🤖 Generated with Claude Code