-
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?
Fix "Something went wrong" error after loading the initial AI answer #3711
Conversation
|
context.dataFetcher.getRevision({ | ||
spaceId: source.space, | ||
revisionId: source.revision, | ||
revisionId, | ||
}) |
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.
Here, we call the getRevisionById
API endpoint using a computed revision ID which looks like this:
computed_kYuvMBuVxyeIcLP8yB1C_306581b1fb17ec1cfde808f99ecb55e092c4e762
Since the source revision ID is embedded inside the computed revision ID, we can extract and use it instead:
https://github.com/GitbookIO/gitbook-x/blob/6811c63ef2ad1381c578c70a54e869ed0af5c797/packages/hive-core/src/computed/revision.ts#L30-L37
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.
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 comment
The 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 getRevisionById
API endpoint) by the source ID, not by the computed ID.
The revision returned by the API is still the computed one:
https://github.com/GitbookIO/gitbook-x/blob/621360305b4c1563e7373e0d35dcac8ab9e495a3/services/cloudrun/api/src/operations/spaces/content/utils.ts#L98-L124
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
…ai-search-returns-something-went-wrong-error-after-loading
// Extract the source revision ID if it's a computed revision. | ||
const revisionId = source.revision.startsWith('computed_') | ||
? (source.revision.split('_')[1] ?? '') | ||
: source.revision; | ||
|
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
This PR ensures that we don't use a computed revision ID when calling the
getRevisionById
API endpoint to display the source pages for an AI answer.Now we extract the source revision ID from the computed revision ID and use it instead.