Skip to content

Improve error message if inventory does not exist in kpt live status.#4660

Open
OisinJohnston2005 wants to merge 1 commit into
kptdev:mainfrom
Nordix:misleading-error-fix
Open

Improve error message if inventory does not exist in kpt live status.#4660
OisinJohnston2005 wants to merge 1 commit into
kptdev:mainfrom
Nordix:misleading-error-fix

Conversation

@OisinJohnston2005

Copy link
Copy Markdown
Contributor

This PR is to fix #2124.

The error message referred to is propagated from cli-utils where they directly print the message to stdout and don't provide any mechanism to catch it.

I added an api call to verify the inventory's existence in kpt live status allowing me to fix the misleading error message, this adds a redundant API call which may not be worth the cleaner output, but the answer to that question is above my paygrade.

…status

Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
@OisinJohnston2005
OisinJohnston2005 requested review from a team July 23, 2026 13:41
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 23, 2026
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 2385b4f
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a621a28d4813d00080afc70
😎 Deploy Preview https://deploy-preview-4660--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@dosubot dosubot Bot added area/live bug Something isn't working labels Jul 23, 2026
@sonarqubecloud

Copy link
Copy Markdown

"sigs.k8s.io/cli-utils/pkg/apply/poller"
"sigs.k8s.io/cli-utils/pkg/inventory"

apierrors "k8s.io/apimachinery/pkg/api/errors"

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.

I think we're trying to remove dependencies with apimachinery.

return invInfo, nil
}

func verifyInventoryExists(ctx context.Context, f util.Factory, invInfo inventory.Info) error {

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.

In this function it would be better to wrap the original error in a more helpful error that you create and that gives context.

the pkgerrors package is useful for this, see:
pkgerrors "github.com/pkg/errors"

see for example:
https://github.com/Nordix/porch/blob/af771881508cea65f4d7c8247c639ff9f424fe6b/pkg/apiserver/apiserver.go#L410

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the original error in the upstream dependency is dumped directly to stdout here so I don't think this solution is viable, this is me implementing Aravindhan's comment on the original issue.

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

Labels

area/live bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kpt live status returns a misleading error if the inventory object doesn't exist

2 participants