Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osbuild-worker: do not use error in clienterror.Error.Details #4145

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented May 13, 2024

This is an alternative/complementary fix for #4137. It is very simple so should be uncontroversial.

It fixes an issue that @schuellerf discovered, i.e. that when an error interface is passed into clienterrors.Error.Details the details get lost because the json.Marshaler will not know how to handler an error interface.

To find the problematic uses of error a custom vet checker was build in https://github.com/mvo5/osbuild-cvet. With that the result is:

$ go run github.com/mvo5/osbuild-cvet@latest ./...
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-depsolve.go:93:26: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:404:31: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:519:31: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:556:31: do not pass '[]error' to WorkerClientError() details, use []string instead

and once this commit is in no more errors.

Just like PR#4137 this is not perfect because it will not do a recursive check for the passed argument.

If we are happy with this approach we should add something like

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 635b1af0b..88f3d831c 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -146,6 +146,9 @@ jobs:
           version: v1.54.2
           args: --verbose --timeout 5m0s
 
+      - name: Run osbuild-cvet
+        run: go run github.com/mvo5/osbuild-cvet@latest ./...
+
   packit-config-lint:
     name: "📦 Packit config lint"
     runs-on: ubuntu-latest

(and move to the vet to the osbuild org)

Copy link
Contributor

@schuellerf schuellerf left a comment

Choose a reason for hiding this comment

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

LGTM

This is an alternative/complementary fix for PR#4137. It is very
simple so should be uncontroverisal.

It fixes an issue that @schuellerf discovered, i.e. that when an error
interface is passed into clienterrors.Error.Details the details get
lost because the json.Marshaler will not know how to handler an
error interface.

To find the problematic uses of `error` a custom vet checker was
build in https://github.com/mvo5/osbuild-cvet. With that the
result is:
```
$ go run github.com/mvo5/osbuild-cvet@latest ./...
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-depsolve.go:93:26: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:404:31: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:519:31: do not pass 'error' to WorkerClientError() details, use error.Error() instead
/home/mvogt/devel/osbuild/osbuild-composer/cmd/osbuild-worker/jobimpl-osbuild.go:556:31: do not pass '[]error' to WorkerClientError() details, use []string instead
```
and once this commit is in no more errors.

Just like PR#4137 this is not perfect because it will not do a
recursive check for the passed argument.
@mvo5 mvo5 enabled auto-merge (rebase) June 6, 2024 07:40
@mvo5 mvo5 merged commit 61bf0c3 into osbuild:main Jun 6, 2024
39 of 67 checks passed
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.

None yet

2 participants