Skip to content

Conversation

chmouel
Copy link
Member

@chmouel chmouel commented Sep 5, 2025

  • Added a new configuration option
    error-log-snippet-number-of-lines. This provides control over the
    number of lines displayed in error log snippets.
  • Set the default value for error-log-snippet-number-of-lines to 3.
  • Implemented a maximum character limit of 65536 for all error log
    snippets. This addressed potential issues with exceeding the GitHub
    Check Run API character limit for logs.
  • Removed a previously hardcoded constant for log snippet lines,
    replacing it with the new configurable setting.
  • Updated the documentation to describe the new configuration and the
    character limit.
  • Add e2e tests with golden to match the output gets proper

Co-authored-by: claude
Jira: https://issues.redhat.com/browse/SRVKP-8165

📝 Description of the Change

🔗 Linked GitHub Issue

Fixes #

👨🏻‍ Linked Jira

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 13:02
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the error logging functionality by introducing a new configurable setting for the number of lines displayed in error log snippets. It also establishes a character limit for these snippets to ensure compatibility with GitHub's Check Run API, providing more control and reliability for error reporting within pull requests.

Highlights

  • New Configuration Option: Introduced a new configuration option error-log-snippet-number-of-lines to control the number of lines displayed in error log snippets.
  • Default Value and Character Limit: Set the default value for error-log-snippet-number-of-lines to 3 and implemented a maximum character limit of 65536 for all error log snippets to prevent exceeding GitHub Check Run API limits.
  • Code Refactoring: Replaced a previously hardcoded constant for log snippet lines with the new configurable setting, improving flexibility.
  • Documentation Update: Updated the documentation to describe the new configuration and the character limit.
  • End-to-End Tests: Added end-to-end tests with golden files to validate the output of the error log snippets with custom line configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code pipelines-as-code bot added documentation Improvements or additions to documentation e2e feature New feature or request gitea labels Sep 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces configurable error log snippet line limits and character restrictions for error reporting in pipelines. The changes improve control over error message display while preventing API character limit violations, particularly for GitHub Check Run API.

  • Added new configuration option error-log-snippet-number-of-lines with default value of 3
  • Implemented 65536 character limit for error log snippets to comply with GitHub Check Run API limits
  • Added end-to-end tests with golden file matching to verify proper output formatting

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config/302-pac-configmap.yaml Adds new configuration setting with documentation
pkg/params/settings/config.go Defines new ErrorLogSnippetNumberOfLines field with default value
pkg/reconciler/status.go Replaces hardcoded constant with configurable value from settings
pkg/kubeinteraction/status/task_status.go Implements character limit enforcement for error snippets
docs/content/docs/install/settings.md Documents new configuration option and character limits
test/gitea_test.go Adds e2e test to verify custom line configuration works
test/pkg/gitea/test.go Adds golden file matching utility function
test/testdata/ Test data and golden files for e2e validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -81,7 +80,11 @@ func (r *Reconciler) updateRepoRunStatus(ctx context.Context, logger *zap.Sugare
}

func (r *Reconciler) getFailureSnippet(ctx context.Context, pr *tektonv1.PipelineRun) string {
taskinfos := kstatus.CollectFailedTasksLogSnippet(ctx, r.run, r.kinteract, pr, logSnippetNumLines)
var lines int64 = 50 // default value
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The default value of 50 lines doesn't match the configured default of 3 lines defined in the Settings struct. This inconsistency could lead to unexpected behavior when the configuration is not loaded properly.

Suggested change
var lines int64 = 50 // default value
var lines int64 = 3 // default value, matches Settings struct

Copilot uses AI. Check for mistakes.

Comment on lines 118 to 119
if len(trimmed) > maxErrorSnippetCharacterLimit {
trimmed = trimmed[:maxErrorSnippetCharacterLimit]
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The character truncation could cut off in the middle of a multi-byte UTF-8 character, potentially causing invalid UTF-8 sequences. Consider using a safe string truncation method that respects UTF-8 character boundaries.

Suggested change
if len(trimmed) > maxErrorSnippetCharacterLimit {
trimmed = trimmed[:maxErrorSnippetCharacterLimit]
runes := []rune(trimmed)
if len(runes) > maxErrorSnippetCharacterLimit {
trimmed = string(runes[:maxErrorSnippetCharacterLimit])
} else {
trimmed = string(runes)
}

Copilot uses AI. Check for mistakes.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration for error log snippet lines, along with documentation and tests. The changes are mostly good, but I've found a few issues. There's a logic error in pkg/reconciler/status.go where an incorrect default value is used. In the tests, there's a compilation error in a new e2e test and a new, unused helper function in test/pkg/gitea/test.go has a misleading name and buggy logic. Please see my detailed comments.

@chmouel chmouel force-pushed the SRVKP-8165-fix-error-log-snippet branch from 28aeabe to 1b2caec Compare September 5, 2025 13:13
@pipelines-as-code pipelines-as-code bot added go Pull requests that update Go code testing labels Sep 5, 2025
@chmouel
Copy link
Member Author

chmouel commented Sep 5, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration option, error-log-snippet-number-of-lines, to control the number of lines in error log snippets, along with a character limit to prevent issues with API limits. The changes include updates to the configuration, documentation, and implementation, supported by new unit and end-to-end tests. My review identified a few areas for improvement: a minor logic simplification, using a more standard library function in a test, and correcting a fallback value that appears to be a copy-paste error. Overall, this is a solid contribution that enhances configurability.

@chmouel chmouel force-pushed the SRVKP-8165-fix-error-log-snippet branch from 1b2caec to 868f8c1 Compare September 5, 2025 13:27
@chmouel
Copy link
Member Author

chmouel commented Sep 5, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a configurable number of lines for error log snippets and a character limit to prevent issues with the GitHub API. The changes are well-implemented and include documentation updates and e2e tests. My main feedback is to correct the value of the character limit, which is currently off by one, to align with GitHub's documentation.

@chmouel chmouel force-pushed the SRVKP-8165-fix-error-log-snippet branch from 868f8c1 to 2849bda Compare September 5, 2025 13:59
*   Added a new configuration option
    `error-log-snippet-number-of-lines`. This provides control over the
    number of lines displayed in error log snippets.
*   Set the default value for `error-log-snippet-number-of-lines` to 3.
*   Implemented a maximum character limit of 65536 for all error log
    snippets. This addressed potential issues with exceeding the GitHub
    Check Run API character limit for logs.
*   Removed a previously hardcoded constant for log snippet lines,
    replacing it with the new configurable setting.
*   Updated the documentation to describe the new configuration and the
    character limit.

Jira: https://issues.redhat.com/browse/SRVKP-8165

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@chmouel chmouel force-pushed the SRVKP-8165-fix-error-log-snippet branch from 2849bda to e4d6b15 Compare September 5, 2025 14:03
@chmouel
Copy link
Member Author

chmouel commented Sep 5, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration option error-log-snippet-number-of-lines to control the number of lines in error log snippets, defaulting to 3. It also enforces a 65535 character limit on these snippets to prevent issues with provider API limits, with UTF-8 safe truncation. The changes are well-implemented, including updates to documentation, configuration, and comprehensive unit and end-to-end tests. My feedback includes a suggestion to simplify the log truncation logic for better readability.

Comment on lines +118 to +123
if len(trimmed) > maxErrorSnippetCharacterLimit {
runes := []rune(trimmed)
if len(runes) > maxErrorSnippetCharacterLimit {
trimmed = string(runes[:maxErrorSnippetCharacterLimit])
}
}

Choose a reason for hiding this comment

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

medium

The logic for truncating the log snippet is a bit complex. The outer if statement checking the byte length (len(trimmed)) is a performance optimization, but it makes the code harder to read. Since this is for an error snippet, which is not expected to be excessively large, we can simplify the logic for better readability and maintainability.

A simpler approach would be to directly work with runes, which is safer for UTF-8 strings anyway.

runes := []rune(trimmed)
if len(runes) > maxErrorSnippetCharacterLimit {
	trimmed = string(runes[:maxErrorSnippetCharacterLimit])
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation e2e feature New feature or request gitea go Pull requests that update Go code testing
Development

Successfully merging this pull request may close these issues.

1 participant