bugfix: fixed 'Could not open the data' error #287
Merged
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.
Fix for 'Could not open the data' error on link-style-button click
Problem
We see an error message: "Could not open the data. It might be invalid or too large. Check the browser console for errors." when clicking artifact links in the chat UI.
Root Cause
The
openBase64InNewTabfunction, which was responsible for opening base64 encoded data in a new tab, was being assigned directly fromthis.safeValuesService.openBase64InNewTabto a property insrc/app/components/chat/chat.component.ts. When this property was invoked from the template, thethiscontext within theopenBase64InNewTabfunction (defined inSafeValuesService) was lost. Consequently, internal calls likethis.openBlobUrl(blob)failed becausethisno longer referred to theSafeValuesServiceinstance, leading to the reported error.Fix
src/app/components/chat/chat.component.ts: The property assignmentprotected openBase64InNewTab = this.safeValuesService.openBase64InNewTab;was replaced with a proper method:typescript protected openBase64InNewTab(dataUrl: string, mimeType: string) { this.safeValuesService.openBase64InNewTab(dataUrl, mimeType); }This ensures that when
openBase64InNewTabis called from the template, it correctly invokes thesafeValuesServicemethod with the properthiscontext.