Skip to content

Conversation

@theakshaypant
Copy link
Contributor

@theakshaypant theakshaypant commented Nov 17, 2025

📝 Description of the Change

Add support for configuring multiple error detection regex patterns at both global (ConfigMap) and repository (CR) levels. This allows users to match different error formats from various linters and tools in a single pipeline.

Global Configuration (ConfigMap):

  • Changed error-detection-simple-regexp to support arrays
  • Supports 3 formats: single pattern (backward compatible), multi-line YAML, and JSON array

Repository CR:

  • Added ErrorDetectionSettings with patterns array and max_number_of_lines
  • Patterns are additive with global patterns
  • Per-repository max_number_of_lines override

👨🏻‍ Linked Jira

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

🔗 Linked GitHub Issue

N/A

🚀 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

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini [email protected]
Co-authored-by: ChatGPT [email protected]
Co-authored-by: Claude [email protected]
Co-authored-by: Cursor [email protected]
Co-authored-by: Copilot [email protected]

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ 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

@theakshaypant
Copy link
Contributor Author

/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 valuable enhancement by adding support for multiple error detection patterns at both the global and repository levels. The implementation is well-structured, with corresponding updates to the CRD, configuration parsing, and documentation. The code is clean and the new tests cover the added functionality. I've found one logic issue where the documented behavior for disabling error detection at the repository level is not correctly implemented. My review includes a suggestion to fix this.

Comment on lines +150 to +152
if repoErrorDetection.Patterns != nil {
patterns = repoErrorDetection.Patterns
}

Choose a reason for hiding this comment

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

high

There's a logic issue here that contradicts the feature's documentation. According to the CRD documentation, providing an empty patterns array (patterns: []) should effectively disable error detection for the repository. However, the current implementation appends the global patterns even when the repository-specific patterns list is empty, causing it to fall back to global patterns instead of disabling detection. This could lead to unexpected behavior for users who want to opt-out of error detection for a specific repository.

To align with the documentation, you should check if repoErrorDetection.Patterns is an empty slice and, if so, stop further pattern processing for this repository.

Suggested change
if repoErrorDetection.Patterns != nil {
patterns = repoErrorDetection.Patterns
}
if repoErrorDetection.Patterns != nil {
// As per documentation, an empty list of patterns disables error detection for the repo.
if len(repoErrorDetection.Patterns) == 0 {
return annotations
}
patterns = repoErrorDetection.Patterns
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have made it more explicit in the docs that empty pattern list WOULD NOT disable error detection for the repo.

@theakshaypant theakshaypant force-pushed the SRVKP-7237-feat-repo-error-detection-setting branch from feefb68 to f922a79 Compare November 17, 2025 05:05
@theakshaypant theakshaypant force-pushed the SRVKP-7237-feat-repo-error-detection-setting branch from f922a79 to a0046de Compare November 17, 2025 05:29
@pipelines-as-code pipelines-as-code bot added documentation Improvements or additions to documentation feature New feature or request labels Nov 17, 2025
Comment on lines +170 to +176
// parseErrorDetectionPatterns parses the error-detection-simple-regexp from ConfigMap
// and populates ErrorDetectionSimpleRegexp as []string. It supports:
// 1. Single string pattern (backward compatible)
// 2. JSON array format: ["pattern1", "pattern2"]
// 3. Newline-separated patterns (YAML multi-line).
func parseErrorDetectionPatterns(setting *Settings, config map[string]string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would love some inputs on this. This approach came to my mind to ensure backward compatibility while allowing multiple patterns as input.

Comment on lines +240 to +242
{{< hint info >}}
**Global Override:** The global `error-detection-from-container-logs` setting
must be enabled (default: `true`) for error detection to work. If disabled
globally, repository-level settings cannot override it.
{{< /hint >}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have kept a global override so admins could disable error detection at an org level (for whatever (?) reason).

@theakshaypant theakshaypant force-pushed the SRVKP-7237-feat-repo-error-detection-setting branch from a0046de to 905496c Compare November 18, 2025 07:58
@theakshaypant theakshaypant marked this pull request as ready for review November 19, 2025 12:43
@theakshaypant theakshaypant force-pushed the SRVKP-7237-feat-repo-error-detection-setting branch from 905496c to 49b7a7c Compare November 20, 2025 05:06
Add support for configuring multiple error detection regex patterns at both
global (ConfigMap) and repository (CR) levels. This allows users to match
different error formats from various linters and tools in a single pipeline.

Global Configuration (ConfigMap):
- Changed error-detection-simple-regexp to support arrays
- Supports 3 formats: single pattern (backward compatible), multi-line YAML,
  and JSON array

Repository CR:
- Added ErrorDetectionSettings with patterns array and max_number_of_lines
- Patterns are additive with global patterns
- Per-repository max_number_of_lines override

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

Signed-off-by: Akshay Pant <[email protected]>
Assisted-by: Cursor <[email protected]>
@theakshaypant theakshaypant force-pushed the SRVKP-7237-feat-repo-error-detection-setting branch from 49b7a7c to b4099d4 Compare November 21, 2025 04:37
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 feature New feature or request github

Development

Successfully merging this pull request may close these issues.

1 participant