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

"Expecting value: line 1 column 1 (char 0)" -- JSONDecodeError("Expecting value", s, err.value) from None #83147

Closed
1 task done
DanielHougaard opened this issue Apr 26, 2024 · 4 comments
Labels
affects_2.16 bug This issue/PR relates to a bug.

Comments

@DanielHougaard
Copy link

Summary

I'm attempting to roll out a new update for my Ansible collection. Whenever it gets to the publishing step it fails with a cryptic JSON decoding error, which seems to point to something going wrong internally in Ansible (perhaps ansible-doc?)

Any help would be greatly appreciated, thank you!

Issue Type

Bug Report

Component Name

infisical_vault

Ansible Version

ansible [core 2.16.4]
  config file = /Users/danielhougaard/Documents/ansible-collection/ansible.cfg
  configured module search path = ['/Users/danielhougaard/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/danielhougaard/.ansible/collections:/usr/share/ansible/collections
  executable location = /Library/Frameworks/Python.framework/Versions/3.12/bin/ansible
  python version = 3.12.0 (v3.12.0:0fb18b02c8, Oct  2 2023, 09:45:56) [Clang 13.0.0 (clang-1300.0.29.30)] (/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12)
  jinja version = 3.1.3
  libyaml = True

Configuration

CONFIG_FILE() = /Users/danielhougaard/Documents/ansible-collection/ansible.cfg
DEFAULT_LOOKUP_PLUGIN_PATH(/Users/danielhougaard/Documents/ansible-collection/ansible.cfg) = ['/Users/danielhougaard/Documents/ansible-collection/plugins/lookup']

OS / Environment

I've tried building & publishing both:

Locally: MacOS 14.1 Sonoma
Github Action: Ubuntu 24.04 LTS

(Building succeeds, but publishing fails)

Steps to Reproduce

The entire collection is open-source, so reproduction should be fairly straight forward.

https://github.com/Infisical/ansible-collection

If you try to publish the collection above, you'll get a cryptic parsing error that seems to stem from inside Ansible, without any pointers to what's actually going wrong other than parsing errors.

Expected Results

I expected the collection to be published.

Actual Results

Importing with galaxy-importer 0.4.20 
Getting doc strings via ansible-doc 

Failed

Expecting value: line 1 column 1 (char 0)
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/tasks/publishing.py", line 115, in import_and_auto_approve
    repo = _upload_collection(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/tasks/publishing.py", line 65, in _upload_collection
    general_create(*general_args, **kwargs)
  File "/venv/lib64/python3.11/site-packages/pulpcore/app/tasks/base.py", line 37, in general_create
    serializer.is_valid(raise_exception=True)
  File "/venv/lib64/python3.11/site-packages/rest_framework/serializers.py", line 227, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/rest_framework/serializers.py", line 429, in run_validation
    value = self.validate(value)
            ^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py", line 484, in validate
    return super().validate(data)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/pulpcore/plugin/serializers/content.py", line 123, in validate
    data = self.deferred_validate(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py", line 494, in deferred_validate
    collection_info = process_collection_artifact(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/pulp_ansible/app/tasks/upload.py", line 37, in process_collection_artifact
    importer_result = import_collection(
                      ^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py", line 78, in import_collection
    return _import_collection(file, filename, file_url, logger, cfg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py", line 135, in _import_collection
    data = CollectionLoader(extract_dir, filename, cfg=cfg, logger=logger).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/collection.py", line 98, in load
    ).load()
      ^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/doc_string.py", line 51, in load
    found_plugins = self._run_ansible_doc_list(plugin_type)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/doc_string.py", line 118, in _run_ansible_doc_list
    return json.loads(stdout)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.16 labels Apr 26, 2024
@ansibot
Copy link
Contributor

ansibot commented Apr 26, 2024

Files identified in the description:

None

If these files are incorrect, please update the component name section of the description or use the component bot command.

@flowerysong
Copy link
Contributor

https://github.com/Infisical/ansible-collection/blob/3f11722a9d978316cb527b1a0e343641c1239201/plugins/lookup/read_secrets.py#L9

Plugins generally shouldn't print things directly; they especially shouldn't do so as a side effect of being loaded.

@s-hertel
Copy link
Contributor

Within the execution of non-module plugins, like here, it is better to use the Display class from ansible.utils.display for debug messages, for example like this https://github.com/ansible/ansible/blob/stable-2.17/lib/ansible/plugins/lookup/url.py#L236.

@DanielHougaard
Copy link
Author

This solved it for us, thank you for the quick responses @s-hertel and @flowerysong! Keep up the great work on Ansible, truly a great product.

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.16 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

5 participants