Use UUID as filename when passing to aichat backend#73451
Conversation
| : file.asset; | ||
| // Use bucketKey as filename so the backend retrieves the correct S3 object. | ||
| // bucketKey is a UUID-based key set at upload time to avoid collisions. | ||
| return asset.bucketKey ? {...asset, filename: asset.bucketKey} : asset; |
There was a problem hiding this comment.
So we are moving from sending the filename to sending the bucketKey?
There was a problem hiding this comment.
Yes! But to Molly's point below, we need both (UUID for getting the file from S3, human-readable name for usage in responses from AI). Updated to that, and added a test to your other point.
| : file.asset; | ||
| // Use bucketKey as filename so the backend retrieves the correct S3 object. | ||
| // bucketKey is a UUID-based key set at upload time to avoid collisions. | ||
| return asset.bucketKey ? {...asset, filename: asset.bucketKey} : asset; |
There was a problem hiding this comment.
Will this cause any confusion with the tutor when referring to these files in the future? Or are the filenames only used for backend lookup?
There was a problem hiding this comment.
hmm good q. I observed files still being appropriately added to the Web Lab project from tutor upload (ie, with human-readable names), so that seemed good. But maybe there's more complexity in tutor having the correct names...let me check.
There was a problem hiding this comment.
Ok yes that makes sense, we'd now be passing the wrong file names to AI Tutor for it to use in its response. I'll switch so we just sort this out on the back end and pass the human readable names to AI Tutor, and just use the UUID for the file lookup.
hannahbergam
left a comment
There was a problem hiding this comment.
Left one question- also is there a way we can test for this?
fisher-alice
left a comment
There was a problem hiding this comment.
Thanks for taking care of this!
|
|
||
| message['assets']&.each do |asset| | ||
| filename = asset["filename"] | ||
| # Newer assets are stored in S3 with a bucketKey (ie, a UUID), but older assets may only have the human-readable filename. |
Follow-up to #72980
We started uploading images in both AI Tutor and AI Chat Lab using UUIDs instead of human-readable filenames. Our AI Chat backend went looking for human-readable filenames and failed. This PR makes it so we pass UUID filenames instead fo the human-readable ones to the backend.
We could also do this on the backend, but made more sense to me to just pass the right filenames from the client. Open to other opinions, though.Switched to doing this check on the backend so we send human-readable filenames to the model to use in its response (thanks Molly!)Links
Testing story
Tested manually that I repro'd the issue before the change, and no longer see it afterwards. Tested in both AI Chat Lab and AI Tutor.