Skip to content

Conversation

utkuufuk
Copy link
Member

@utkuufuk utkuufuk commented Oct 8, 2025

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.

Copy link

linear bot commented Oct 8, 2025

Copy link

changeset-bot bot commented Oct 8, 2025

⚠️ No Changeset found

Latest commit: 76599ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines 168 to 171
context.dataFetcher.getRevision({
spaceId: source.space,
revisionId: source.revision,
revisionId,
})
Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

@utkuufuk utkuufuk Oct 10, 2025

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

Copy link

argos-ci bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 4 changed Oct 9, 2025, 8:40 AM
v2-cloudflare (Inspect) 👍 Changes approved 5 changed Oct 9, 2025, 8:44 AM
v2-vercel (Inspect) 👍 Changes approved 6 changed Oct 9, 2025, 8:43 AM

@utkuufuk utkuufuk changed the title Fix AI search returning "Something went wrong" error after loading the initial response Fix "Something went wrong" error after loading the initial AI answer Oct 8, 2025
…ai-search-returns-something-went-wrong-error-after-loading
Comment on lines +160 to +164
// Extract the source revision ID if it's a computed revision.
const revisionId = source.revision.startsWith('computed_')
? (source.revision.split('_')[1] ?? '')
: source.revision;

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants