Skip to content

OCPBUGS-77952: Fix devfile sample import by adding fallback for parent resolution failures#16149

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
jhadvig:OCPBUGS-77952
May 12, 2026
Merged

OCPBUGS-77952: Fix devfile sample import by adding fallback for parent resolution failures#16149
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
jhadvig:OCPBUGS-77952

Conversation

@jhadvig

@jhadvig jhadvig commented Mar 16, 2026

Copy link
Copy Markdown
Member

Summary:

  • Devfile samples with parent references (e.g., go-basic) fail when the vendored devfile library's OCI pull of parent stack resources from registry.devfile.io breaks, keeping the submit button permanently disabled
  • Add fallback: try flattened parse first, retry without parent resolution on failure
  • Safe because the console backend only uses outer-loop components (image, kubernetes, deploy command) which are all defined in the child devfile

/assign @vikram-raj

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Implemented automatic fallback mechanism for devfile parsing to gracefully handle complex configurations and improve overall reliability.
    • Enhanced handling of devfiles with unreachable registry references or missing parent resources.
  • Tests

    • Added comprehensive test coverage for devfile parsing fallback scenarios.

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Mar 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jhadvig: This pull request references Jira Issue OCPBUGS-77952, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary:

  • Devfile samples with parent references (e.g., go-basic) fail when the vendored devfile library's OCI pull of parent stack resources from registry.devfile.io breaks, keeping the submit button permanently disabled
  • Add fallback: try flattened parse first, retry without parent resolution on failure
  • Safe because the console backend only uses outer-loop components (image, kubernetes, deploy command) which are all defined in the child devfile

/assign @vikram-raj

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Mar 16, 2026
@openshift-ci openshift-ci Bot requested review from Leo6Leo and TheRealJon March 16, 2026 14:33
@openshift-ci openshift-ci Bot added component/backend Related to backend approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 16, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jhadvig: This pull request references Jira Issue OCPBUGS-77952, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

Summary:

  • Devfile samples with parent references (e.g., go-basic) fail when the vendored devfile library's OCI pull of parent stack resources from registry.devfile.io breaks, keeping the submit button permanently disabled
  • Add fallback: try flattened parse first, retry without parent resolution on failure
  • Safe because the console backend only uses outer-loop components (image, kubernetes, deploy command) which are all defined in the child devfile

/assign @vikram-raj

Summary by CodeRabbit

Release Notes

  • Bug Fixes

  • Implemented automatic fallback mechanism for devfile parsing to gracefully handle complex configurations and improve overall reliability.

  • Enhanced handling of devfiles with unreachable registry references or missing parent resources.

  • Tests

  • Added comprehensive test coverage for devfile parsing fallback scenarios.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested a review from yapei March 16, 2026 14:36
@coderabbitai

coderabbitai Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request introduces a two-stage devfile parsing mechanism to improve resilience when handling parent and plugin references. A new parseDevfileWithFallback function attempts parsing with full parent/plugin resolution (flattened) first, then retries with flattening disabled if the initial attempt fails. The DevfileHandler delegates to this function rather than directly calling ParseDevfileAndValidate. New test coverage validates the fallback behavior with three scenarios: successful parsing without parents, fallback retry when a registry is unreachable, and error handling for invalid YAML input.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing a fallback mechanism for devfile parent resolution failures to fix sample imports.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/devfile/handler.go (1)

43-58: Gate fallback retries to network/resolution failures; skip for schema violations.

Line 51 currently retries unflattened parsing for any ParseDevfileAndValidate error, including schema validation and YAML syntax failures. This burns unnecessary cycles for invalid inputs and obscures root-cause diagnostics. Since the handler at line 86 already inspects error messages, add a guard before the retry—return the original error immediately for validation failures, and only retry for parent/plugin/OCI resolution timeouts:

 	if err == nil {
 		return devfileObj, nil
 	}
+
+	if !shouldRetryUnflattened(err) {
+		return parser.DevfileObj{}, err
+	}
 
 	klog.Warningf("Flattened devfile parse failed, retrying without parent resolution: %v", err)
 
 	flattenedDevfile := false
 	devfileObj, _, err = devfile.ParseDevfileAndValidate(parser.ParserArgs{
 		Data:             devfileContentBytes,
 		HTTPTimeout:      httpTimeout,
 		FlattenedDevfile: &flattenedDevfile,
 	})
 	return devfileObj, nil
+}
+
+func shouldRetryUnflattened(err error) bool {
+	msg := strings.ToLower(err.Error())
+	return strings.Contains(msg, "oci") ||
+		strings.Contains(msg, "parent") ||
+		strings.Contains(msg, "registry") ||
+		strings.Contains(msg, "timeout") ||
+		strings.Contains(msg, "connection refused")
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/devfile/handler.go` around lines 43 - 58, The current retry always calls
devfile.ParseDevfileAndValidate a second time (setting FlattenedDevfile) even
for validation/YAML errors; change the handler to inspect the original err from
devfile.ParseDevfileAndValidate and only perform the flattened-devfile retry
when the error indicates network/resolution/timeout issues (parent/plugin/OCI
resolution failures), otherwise return the original error immediately; use the
same error inspection approach already used later in the file (the handler's
existing error message checks) to detect validation/schema/YAML errors versus
resolution/timeouts before creating flattenedDevfile and re-calling
devfile.ParseDevfileAndValidate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/devfile/handler_test.go`:
- Around line 65-66: The test currently relies on an external DNS name via the
registryUrl YAML value and a long wait (about 10s), causing CI flakiness; update
the fallback test to use a deterministic local failure target (replace
registryUrl: 'https://does-not-exist.invalid' with 'http://127.0.0.1:1') and
shorten the related wait/timeout (the ~10s backoff used in the test) to a small
value like 200–500ms so the test fails fast; locate the registryUrl string in
the test fixture and the timeout/wait variable used around the fallback
assertion and make these two changes.

---

Nitpick comments:
In `@pkg/devfile/handler.go`:
- Around line 43-58: The current retry always calls
devfile.ParseDevfileAndValidate a second time (setting FlattenedDevfile) even
for validation/YAML errors; change the handler to inspect the original err from
devfile.ParseDevfileAndValidate and only perform the flattened-devfile retry
when the error indicates network/resolution/timeout issues (parent/plugin/OCI
resolution failures), otherwise return the original error immediately; use the
same error inspection approach already used later in the file (the handler's
existing error message checks) to detect validation/schema/YAML errors versus
resolution/timeouts before creating flattenedDevfile and re-calling
devfile.ParseDevfileAndValidate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c233660d-44f2-4076-bf3d-b052fc6548a2

📥 Commits

Reviewing files that changed from the base of the PR and between 4d1f6f7 and dc59323.

📒 Files selected for processing (2)
  • pkg/devfile/handler.go
  • pkg/devfile/handler_test.go

Comment on lines +65 to +66
registryUrl: 'https://does-not-exist.invalid'
components:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove external DNS/network dependency from fallback test.

The fallback case currently depends on resolving an external invalid domain (Line 65) and can wait up to 10s (Line 111), which may cause CI flakiness/latency. Use a deterministic local failure target (for example http://127.0.0.1:1) and a shorter timeout.

Proposed test hardening
-  registryUrl: 'https://does-not-exist.invalid'
+  registryUrl: 'http://127.0.0.1:1'
@@
-	httpTimeout := 10
+	httpTimeout := 1

Also applies to: 111-125

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/devfile/handler_test.go` around lines 65 - 66, The test currently relies
on an external DNS name via the registryUrl YAML value and a long wait (about
10s), causing CI flakiness; update the fallback test to use a deterministic
local failure target (replace registryUrl: 'https://does-not-exist.invalid' with
'http://127.0.0.1:1') and shorten the related wait/timeout (the ~10s backoff
used in the test) to a small value like 200–500ms so the test fails fast; locate
the registryUrl string in the test fixture and the timeout/wait variable used
around the fallback assertion and make these two changes.

@vikram-raj

Copy link
Copy Markdown
Member

/retest

@vikram-raj vikram-raj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Mar 17, 2026

@logonoff logonoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jhadvig

jhadvig commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

@logonoff +1

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2026
@jhadvig

jhadvig commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

@logonoff comment addressed 👍
@vikram-raj PTAL

@openshift-ci openshift-ci Bot added the component/dev-console Related to dev-console label Apr 1, 2026
@logonoff

logonoff commented Apr 1, 2026

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2026
@openshift-ci

openshift-ci Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, logonoff, vikram-raj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Leo6Leo

Leo6Leo commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

/retest-required

1 similar comment
@Leo6Leo

Leo6Leo commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

/retest-required

@jhadvig

jhadvig commented Apr 2, 2026

Copy link
Copy Markdown
Member Author

Overriding since the CI passed for the previous revision, and the only change was enabling two disabled e2e tests.
Fialed tests have been flakes.

/override ci/prow/e2e-gcp-console

@openshift-ci

openshift-ci Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

@jhadvig: Overrode contexts on behalf of jhadvig: ci/prow/e2e-gcp-console

Details

In response to this:

Overriding since the CI passed for the previous revision, and the only change was enabling two disabled e2e tests.
Fialed tests have been flakes.

/override ci/prow/e2e-gcp-console

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jhadvig jhadvig added the plugin-api-approved Indicates a PR with plugin API changes has been approved by an API reviewer label Apr 2, 2026
@jhadvig

jhadvig commented Apr 2, 2026

Copy link
Copy Markdown
Member Author

@yapei PTAL

@openshift-bot

Copy link
Copy Markdown
Contributor

/jira refresh

The requirements for Jira bugs have changed (Jira issues linked to PRs on main branch need to target different OCP), recalculating validity.

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@openshift-bot: This pull request references Jira Issue OCPBUGS-77952, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

/jira refresh

The requirements for Jira bugs have changed (Jira issues linked to PRs on main branch need to target different OCP), recalculating validity.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

@openshift-ci-robot: GitHub didn't allow me to request PR reviews from the following users: yapei.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

@openshift-bot: This pull request references Jira Issue OCPBUGS-77952, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

/jira refresh

The requirements for Jira bugs have changed (Jira issues linked to PRs on main branch need to target different OCP), recalculating validity.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@logonoff

logonoff commented May 7, 2026

Copy link
Copy Markdown
Member

/test all
/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label May 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@logonoff: This PR has been marked as verified by CI.

Details

In response to this:

/test all
/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@logonoff

Copy link
Copy Markdown
Member

/test all

@openshift-ci

openshift-ci Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

@jhadvig: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit 3691ae5 into openshift:main May 12, 2026
8 checks passed
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jhadvig: Jira Issue Verification Checks: Jira Issue OCPBUGS-77952
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-77952 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

Summary:

  • Devfile samples with parent references (e.g., go-basic) fail when the vendored devfile library's OCI pull of parent stack resources from registry.devfile.io breaks, keeping the submit button permanently disabled
  • Add fallback: try flattened parse first, retry without parent resolution on failure
  • Safe because the console backend only uses outer-loop components (image, kubernetes, deploy command) which are all defined in the child devfile

/assign @vikram-raj

Summary by CodeRabbit

Release Notes

  • Bug Fixes

  • Implemented automatic fallback mechanism for devfile parsing to gracefully handle complex configurations and improve overall reliability.

  • Enhanced handling of devfiles with unreachable registry references or missing parent resources.

  • Tests

  • Added comprehensive test coverage for devfile parsing fallback scenarios.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jhadvig

jhadvig commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick release-4.22

@openshift-cherrypick-robot

Copy link
Copy Markdown

@jhadvig: new pull request created: #16706

Details

In response to this:

/cherry-pick release-4.22

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend component/dev-console Related to dev-console jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. plugin-api-approved Indicates a PR with plugin API changes has been approved by an API reviewer verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants