Skip to content
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

Build Fails When the Buildkite Annotation is Too Long #1331

Open
ConradLang opened this issue Dec 7, 2023 · 3 comments
Open

Build Fails When the Buildkite Annotation is Too Long #1331

ConradLang opened this issue Dec 7, 2023 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ConradLang
Copy link
Contributor

The maximum body size of a Buildkite annotation is 1 MiB as per Buildkite - Creating an annotation.

When the body size is greater than 1 MiB, an error occurs (e.g. backoffice-access Build 1727 Line 2604)

Error: Command failed with E2BIG: buildkite-agent annotate --context build-associations.association-diff --style warning ...

The Buildkite.annotate function could possibly truncate the annotation similar to buildkite-plugins/junit-annotate-buildkite-plugin L28-L32 (as suggested by @72636c in Slack) although that may break the annotation anyway or result in an inaccurate annotation.

@72636c 72636c added bug Something isn't working good first issue Good for newcomers labels Dec 7, 2023
@GeordieEK
Copy link
Contributor

GeordieEK commented Apr 27, 2024

Would it be feasible to split offending annotation bodies into multiple annotations?
I'm not too familiar with buildkite nor do I have access to that particular error, but maybe something like this?

@ConradLang
Copy link
Contributor Author

Splitting the annotation bodies into multiple annotations is an option but you'd then need to consider deleting the annotations when you re-run the step and need to delete / update the annotations.

While it should not be complicated to find and delete the related annotations (assuming there's a naming convention), it would be simpler to truncate the annotation but write the full message to the build log such that the information is still available even if not in the annotation.

@GeordieEK
Copy link
Contributor

GeordieEK commented May 7, 2024

The annotation truncation seems to be working, I've included a warning as well.

What's the best way to write to the build log? Thanks

  // Check if the annotation exceeds the maximum size
  const buffer = Buffer.from(markdown, 'utf-8');
  let truncatedMarkdown = markdown;
  if (buffer.length > MAX_SIZE) {
    // Notify user of truncation, leave space for message
    truncatedMarkdown =
      buffer.toString('utf-8', 0, MAX_SIZE - TRUNCATION_WARNING.length) +
      TRUNCATION_WARNING;
    // TODO: Log the full annotation to the build log
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants