Skip to content

fix(plugins): require image ref on same line as image: key#2002

Open
joluc wants to merge 1 commit into
mainfrom
fix/ocimirror-regex-false-positive
Open

fix(plugins): require image ref on same line as image: key#2002
joluc wants to merge 1 commit into
mainfrom
fix/ocimirror-regex-false-positive

Conversation

@joluc
Copy link
Copy Markdown
Contributor

@joluc joluc commented May 20, 2026

Description

The image-extraction regex used \s+ which matches across newlines, causing false positives when image: opens a nested YAML map (e.g. CRD field schemas like OpenSearch index templates declaring an OTLP container.image.{name,tag} field). The next YAML key was captured as a bogus image reference, and the subsequent ParseReference call failed the entire Plugin reconcile.

Tighten the regex to require whitespace-only inline (\t and space) between image: and the value, plus an end-of-line anchor.

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Copilot AI review requested due to automatic review settings May 20, 2026 11:46
@joluc joluc requested a review from a team as a code owner May 20, 2026 11:46
@joluc joluc changed the title fix(ocimirror): require image ref on same line as image: key fix(plugins): require image ref on same line as image: key May 20, 2026
Copy link
Copy Markdown
Contributor

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 fixes OCI image reference extraction in internal/ocimirror by preventing the regex from matching across newlines when encountering YAML keys named image: that open nested maps (common in CRD schemas). This avoids false-positive image refs that previously could cause ParseReference failures and break Plugin reconciles.

Changes:

  • Tightened the image: extraction regex to require inline-only whitespace and an end-of-line match.
  • Added a regression test ensuring nested-map image: keys (e.g., CRD field schemas) are ignored.

Reviewed changes

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

File Description
internal/ocimirror/ociref.go Updates imageFieldPattern to only match image: <ref> when the ref is on the same line.
internal/ocimirror/ociref_test.go Adds a regression test for nested-map image: usage to prevent false positives.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@joluc joluc force-pushed the fix/ocimirror-regex-false-positive branch 2 times, most recently from 7ec863e to d24408e Compare May 20, 2026 11:49
@abhijith-darshan abhijith-darshan force-pushed the fix/ocimirror-regex-false-positive branch from d24408e to 180f001 Compare May 21, 2026 07:33
Copy link
Copy Markdown
Contributor

@abhijith-darshan abhijith-darshan left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@abhijith-darshan abhijith-darshan force-pushed the fix/ocimirror-regex-false-positive branch from 180f001 to c409559 Compare May 21, 2026 08:21
Signed-off-by: Jonathan Schwarze <jonathan.schwarze@sap.com>
@abhijith-darshan abhijith-darshan force-pushed the fix/ocimirror-regex-false-positive branch from eb1f34b to e217d5c Compare May 22, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [BUG] - Image replication regex matches OpenSearch index template image field, breaks Plugin reconcile

3 participants