Figure out how to deal with leaky comment IDs in the web API #652
Labels
No labels
ai-review-please
Org/Team Modification
Private Issues
Runner Request
Backlog Status
Needs Review
Backlog Status
Ready
chore
documentation
points
01
points
02
points
03
points
05
points
08
points
13
Priority
High
Priority
Low
Priority
Medium
Sprint Status
Blocked
Sprint Status
Done
Sprint Status
In Progress
Sprint Status
Review
Sprint Status
To Do
Technical Debt
Work Item
Bug
Work Item
Epic
Work Item
Spike
Work Item
Task
Work Item
User Story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#594 Private Issues: “Privatize” Comments
forge/forge
Reference
forge/forge#652
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
We are looking for a way to identify comments in the public web API.
Acceptance Criteria
IDvalues as keys.Background
Comment.IDis leaked into the public API.IDfields, so just this number alone isn’t unique to address a comment.IDfield ofCommentand/orPrivateComment.Thoughts:
autoincrfrom theIDprimary key field ofComment. This could require recreating the table (depending on how we go about it), which is complicated.My preferred option would be to “steal” the auto-incrementing
Comment.IDfor creatingPrivateCommententries:Embed the originalOverride theCommenttype intoPrivateCommentandIDfield so it doesn’t getautoincr(just in case). Because embedding one type into another changes how literals of the extended type work (… in hundreds of places …), this is not really feasible. But we don’t really want to change the structure, just how XORM creates the table column, so we can use thereflectpackage to synthesize a modified copy of the type (which just changes the XORM tag on the ID column) and use that at startup fordb.RegisterModel().Upside: unique IDs make linking to them clearly “just happen” and seamless conversion between public and private easy. No need to store an original ID or similar.
Downside: It makes both creating a new private comment in the database and creating the table in the first place a little more involved.
An ostensibly cleaner variation would be to have a third table only for the IDs, but then you’d have to start looking them up elsewhere (whenever you need to look up an ID/a key).
For completeness sake, we could use prefixes:
Upside: we wouldn’t have to deal with ID fields in Comment vs. PrivateComment any special
Downside: we’d have to store this for the key to be stable across conversions public <=> private, and it would look funky to have a prefixed key for a public comment
A non-option would be to just not care, simply use the database IDs verbatim and cross fingers that we don’t run into collisions. Which would admittedly be rare, but this doesn’t mean impossible.
Another one would be switching to uuids, which would be a good idea if we started from scratch, but this would break existing links to comments.
commentandprivate_commenttables to share unique IDs between them #664