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

Passing type as part of --artifact-remote url raises unhandled error #1843

Closed
abderrahim opened this issue May 18, 2023 · 1 comment · Fixed by #1850
Closed

Passing type as part of --artifact-remote url raises unhandled error #1843

abderrahim opened this issue May 18, 2023 · 1 comment · Fixed by #1850

Comments

@abderrahim
Copy link
Contributor

Trying to add an artifact cache by passing it on the command line. I have the following arguments added to bst build.

--artifact-remote url=http://example.com:8982,type=index --artifact-remote url=http://example.com:8980,type=storage

I get this error:

Traceback (most recent call last):
  File "/home/abderrahimkitouni/.local/bin/bst", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/buildstream/_frontend/cli.py", line 271, in override_main
    original_main(self, args=args, prog_name=prog_name, complete_var=None, standalone_mode=standalone_mode, **extra)
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 1655, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 920, in make_context
    self.parse_args(ctx, args)
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 1378, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 2360, in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 2316, in process_value
    value = self.type_cast_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 2302, in type_cast_value
    return tuple(convert(x) for x in check_iter(value))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/core.py", line 2302, in <genexpr>
    return tuple(convert(x) for x in check_iter(value))
                 ^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/click/types.py", line 82, in __call__
    return self.convert(value, param, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/buildstream/_frontend/cli.py", line 62, in convert
    spec = RemoteSpec.new_from_string(value, self.purpose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/buildstream/_remotespec.py", line 316, in new_from_string
    if remote_type not in [RemoteType.INDEX, RemoteType.STORAGE, RemoteType.ALL]:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/abderrahimkitouni/.local/pipx/venvs/buildstream/lib/python3.11/site-packages/buildstream/types.py", line 70, in __eq__
    raise ValueError("Unexpected comparison between {} and {}".format(self, repr(other)))
ValueError: Unexpected comparison between index and 'index'

It seems it is trying to compare the string 'index' with the enum value RemoteType.INDEX and failing.

cs-shadow added a commit that referenced this issue Jul 26, 2023
@cs-shadow cs-shadow changed the title Passing type=storage or type=index on the command line raises error Passing type as part of --artifact-remote url raises error Jul 26, 2023
@cs-shadow cs-shadow changed the title Passing type as part of --artifact-remote url raises error Passing type as part of --artifact-remote url raises unhandled error Jul 26, 2023
cs-shadow added a commit that referenced this issue Jul 26, 2023
@cs-shadow
Copy link
Member

I think this issue affects passing the type option in general, and not any particular values.

You're also right that it seems to be stemming from incorrect comparisons between strings and ENUMs. #1850 should fix it I believe, reviews appreciated :)

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 a pull request may close this issue.

2 participants