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

[JUJU-3456] Fix returned error when yaml is invalid on diff-bundle #15497

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

nvinuesa
Copy link
Member

@nvinuesa nvinuesa commented Apr 18, 2023

When dealing with invalid yaml in local bundle, the error was treated as if the file was not present, therefore continuing to treat the input as a charm bundle url.

This patch fixes the returned error if it's a NotValid error.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing
  • Integration tests, with comments saying what you're testing
  • doc.go added or updated in changed packages

QA steps

Having an empty juju model and this test.yaml bundle:

series: focal
applications:
  ubuntu:
    charm: ubuntu
    channel: stable
    revision: 21
    num_units: 1
    to:
    - "0"
    constraints: arch=amd64
va
machines:
  "0":
    constraints: arch=amd64

then you should get this error:

$ juju diff-bundle test.yaml
ERROR cannot unmarshal bundle contents: unmarshal document 0: yaml: line 12: could not find expected ':'

if you remove line 12 then:

$ juju diff-bundle test.yaml
applications:
  ubuntu:
    missing: model
machines:
  "0":
    missing: model

Bug reference

https://bugs.launchpad.net/juju/+bug/2015315

When dealing with invalid yaml in local bundle, the error was treated as
if the file was not present, therefore continuing to treat the input as
a charm bundle url. This fix returns the error if it's a NotValid error.
@hpidcock hpidcock added the 2.9 label Apr 18, 2023
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

I'm unsure why we thought an invalid bundle.yaml should be interpreted and treated as a charm store charm. This is over 4-year-old code, I suspect the original assumption was incorrect or the underlying library has changed.

@nvinuesa
Copy link
Member Author

/merge

@jujubot jujubot merged commit d7770fc into juju:2.9 Apr 19, 2023
@jack-w-shaw jack-w-shaw mentioned this pull request Apr 19, 2023
jujubot added a commit that referenced this pull request Apr 20, 2023
#15506

Merges:
- #15487
- #15490
- #15492
- #15499
- #15497

Conflicts solved trivially:
- provider/maas/environprovider.go
- tests/suites/spaces_ec2/util.sh
@barrettj12 barrettj12 mentioned this pull request May 9, 2023
jujubot added a commit that referenced this pull request May 9, 2023
@barrettj12 barrettj12 mentioned this pull request May 10, 2023
jujubot added a commit that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants