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

fix: default value for MOZ_FETCHES in integration test transform should be an empty object #221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bhearsum
Copy link
Contributor

An empty string is not valid JSON:

import json
json.loads("")
Traceback (most recent call last):
File "", line 1, in
File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

…ld be an empty json object

An empty string is not valid JSON:
>>> import json
>>> json.loads("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bhearsum/.pyenv/versions/3.11.6/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@bhearsum bhearsum requested a review from a team as a code owner December 13, 2024 20:47
Copy link
Contributor

@hneiva hneiva left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -42,7 +42,7 @@ def make_firefoxci_artifact_tasks(config, tasks):
# Add private artifacts
if "MOZ_FETCHES" in task_def["payload"].get("env", {}):
fetches = json.loads(
task_def["payload"].get("env", {}).get("MOZ_FETCHES", {})
task_def["payload"].get("env", {}).get("MOZ_FETCHES", "{}")
Copy link
Contributor

Choose a reason for hiding this comment

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

super nitty: could also do a check if env := task_def["payload"].get("env"):.... for arguably more performance. But give this only runs once, it should be fine too.

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.

2 participants