-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix "Something went wrong" error after loading the initial AI answer #3711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,12 +157,17 @@ export async function streamAskQuestion({ | |
} | ||
|
||
if (!spacePromises.has(source.space)) { | ||
// Extract the source revision ID if it's a computed revision. | ||
const revisionId = source.revision.startsWith('computed_') | ||
? (source.revision.split('_')[1] ?? '') | ||
: source.revision; | ||
|
||
spacePromises.set( | ||
source.space, | ||
throwIfDataError( | ||
context.dataFetcher.getRevision({ | ||
spaceId: source.space, | ||
revisionId: source.revision, | ||
revisionId, | ||
}) | ||
Comment on lines
168
to
171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, we call the
Since the source revision ID is embedded inside the computed revision ID, we can extract and use it instead: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But why ? we should work with the actual computed revision; this is what is indexed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SamyPesse We extract the pages from the revision so we can display relevant pages along with the AI answer. However, we can only look up revisions (from Hive, via the The revision returned by the API is still the computed one: |
||
) | ||
); | ||
|
@@ -175,8 +180,15 @@ export async function streamAskQuestion({ | |
// Get the pages for all spaces referenced by this answer. | ||
const pages = await Promise.all( | ||
spaces.map(async (space) => { | ||
const revision = await spacePromises.get(space); | ||
return { space, pages: revision?.pages }; | ||
try { | ||
const revision = await spacePromises.get(space); | ||
return { space, pages: revision?.pages }; | ||
} catch (err) { | ||
console.error('Error getting revision', err); | ||
// TODO: should we swallow the error as it's not essential to the answer? | ||
// return { space, pages: null }; | ||
throw err; | ||
} | ||
}) | ||
).then((results) => { | ||
return results.reduce((map, result) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's the right fix. computed IDs can change format in the future. It's risky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah definitelly we should NEVER NEVER do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it's plain wrong, the second part is not the revision ID