Skip to content

fix(remediation): create remediation#1190

Open
kanstantsinbuklis-sap wants to merge 2 commits into
mainfrom
kanstantsinbuklis-sap/issue-1189/fix-create-remediation
Open

fix(remediation): create remediation#1190
kanstantsinbuklis-sap wants to merge 2 commits into
mainfrom
kanstantsinbuklis-sap/issue-1189/fix-create-remediation

Conversation

@kanstantsinbuklis-sap
Copy link
Copy Markdown
Collaborator

Description

In this PR I've changed the logic of creating remediation. Previously we could get more components than expected that's why process of creating was failing

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)

Added to documentation?

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

@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1189/fix-create-remediation branch from 39c65ef to 0f0e9f6 Compare May 8, 2026 11:44
@kanstantsinbuklis-sap kanstantsinbuklis-sap marked this pull request as ready for review May 8, 2026 12:18
Copilot AI review requested due to automatic review settings May 8, 2026 12:18
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 adjusts remediation creation to avoid resolving the wrong (or ambiguous) component context, addressing failures like “component id not found” when multiple components match the provided input.

Changes:

  • Updated CreateRemediation mutation to resolve issue first, then narrow down to a single component version and component.
  • Improved E2E remediation creation setup to use a service/component/issue triple that is known to be linked in seeded data.
  • Adjusted DB seeding to better preserve repository/linkage data used by remediation creation.

Reviewed changes

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

File Description
internal/api/graphql/graph/resolver/mutation.go Refines remediation creation lookup flow by resolving issue → component version → component to reduce ambiguous matches.
internal/database/mariadb/test/fixture.go Adds helper to find linked remediation seed data and tweaks seeding to align repository/linkage fields for tests.
internal/e2e/remediation_query_test.go Uses linked seeded service/component/issue data to make remediation creation E2E deterministic.

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

Comment thread internal/database/mariadb/test/fixture.go Outdated
Comment on lines 1052 to 1056
if err != nil || len(issueResult.Elements) == 0 || len(issueResult.Elements) > 1 {
return nil, baseResolver.NewResolverError(
"CreateRemediationMutationResolver",
"Internal Error - when creating remediation - component id not found",
"Internal Error - when creating remediation - issue id not found",
)
Comment on lines +1073 to +1078
if err != nil || len(componentVersionResult.Elements) == 0 || len(componentVersionResult.Elements) > 1 {
return nil, baseResolver.NewResolverError(
"CreateRemediationMutationResolver",
"Internal Error - when creating remediation - component version not found",
)
}
nil,
)
if err != nil || len(issueResult.Elements) == 0 || len(issueResult.Elements) > 1 {
if err != nil || len(componentResult.Elements) == 0 || len(componentResult.Elements) > 1 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not to check != 1 to reduce mc

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Just copy-paste error handling from code above. Fixed this in several parts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Boy Scout Rule

Signed-off-by: Kanstantsin Buklis <kanstantsin.buklis@sap.com>
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1189/fix-create-remediation branch from 0f0e9f6 to a586756 Compare May 11, 2026 12:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Kanstantsin Buklis <kanstantsin.buklis@sap.com>
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1189/fix-create-remediation branch from 99a1f15 to db588be Compare May 11, 2026 14:02
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.

3 participants