Skip to content

indexserver: truncate failure messages in status updates#1070

Merged
stefanhengl merged 2 commits into
mainfrom
stefanhengl/assess-error-truncation
Jun 5, 2026
Merged

indexserver: truncate failure messages in status updates#1070
stefanhengl merged 2 commits into
mainfrom
stefanhengl/assess-error-truncation

Conversation

@stefanhengl

@stefanhengl stefanhengl commented Jun 5, 2026

Copy link
Copy Markdown
Member

Truncate failure messages to 12 KiB before sending index status updates to Sourcegraph. This limit is modeled after Kubernetes, which similarly truncates termination messages on the assumption that complete failure details are available in container logs.

@stefanhengl stefanhengl force-pushed the stefanhengl/assess-error-truncation branch 4 times, most recently from 1de4904 to 66d68d2 Compare June 5, 2026 09:36
@stefanhengl stefanhengl force-pushed the stefanhengl/assess-error-truncation branch from 66d68d2 to b671170 Compare June 5, 2026 09:37
@stefanhengl stefanhengl marked this pull request as ready for review June 5, 2026 09:44
@stefanhengl stefanhengl requested a review from keegancsmith June 5, 2026 09:44
maxBytes--
}

return s[:maxBytes]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally the end of logs are more interesting? We have some code (maybe in our monorepo) which was adapted from the stdlib which preserves the head and tail, then cuts in the middle. Would that be useful to use?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to middle truncation. I didn't use the helper from the monorepo because we don't need to support streaming.

Comment on lines +767 to +769
for maxBytes > 0 && !utf8.RuneStart(s[maxBytes]) {
maxBytes--
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

@stefanhengl stefanhengl merged commit 893a523 into main Jun 5, 2026
7 checks passed
@stefanhengl stefanhengl deleted the stefanhengl/assess-error-truncation branch June 5, 2026 12:22
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.

2 participants