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

JSON decode error #7216

Closed
cmyers009 opened this issue Jul 2, 2024 · 4 comments
Closed

JSON decode error #7216

cmyers009 opened this issue Jul 2, 2024 · 4 comments
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale.

Comments

@cmyers009
Copy link

Multiple people are encountering this issue within the span of an hours time.  I suspect a recent update is causing this issue.

I have built my sam application many times before with no changes, and received no issues, but I ran it just now, and got the following error:
```Running PythonPipBuilder:CopySource

Error: Expecting value: line 1 column 1 (char 0)
Traceback:
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/cli/cli_config_file.py", line 347, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/telemetry/metric.py", line 185, in wrapped
raise exception # pylint: disable=raising-bad-type
^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/telemetry/metric.py", line 150, in wrapped
return_value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/utils/version_checker.py", line 43, in wrapped
actual_result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/cli/main.py", line 95, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/commands/build/command.py", line 169, in cli
do_cli(
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/commands/build/command.py", line 258, in do_cli
ctx.run()
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/commands/build/build_context.py", line 284, in run
self._build_result = builder.build()
^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/app_builder.py", line 226, in build
return ApplicationBuildResult(build_graph, build_strategy.build())
^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 416, in build
return super().build()
^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 83, in build
result.update(self._build_functions(self._build_graph))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 422, in _build_functions
return self._run_builds_async(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 438, in _run_builds_async
async_results = async_context.run_async()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/utils/async_utils.py", line 137, in run_async
return run_given_tasks_async(self._async_tasks, event_loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/utils/async_utils.py", line 96, in run_given_tasks_async
return event_loop.run_until_complete(_run_given_tasks_async(tasks, event_loop, executor))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/utils/async_utils.py", line 62, in _run_given_tasks_async
raise result
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 449, in build_single_function_definition
return self._delegate_build_strategy.build_single_function_definition(build_definition)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 595, in build_single_function_definition
return self._cached_build_strategy.build_single_function_definition(build_definition)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 303, in build_single_function_definition
build_result = self._delegate_build_strategy.build_single_function_definition(build_definition)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/build_strategy.py", line 168, in build_single_function_definition
result = self._build_function(
^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/app_builder.py", line 723, in _build_function
return self._build_function_on_container(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/app_builder.py", line 982, in _build_function_on_container
response = self._parse_builder_response(stdout_data, container.image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/_temp/setup-sam-Nes3v1/.venv/lib/python3.11/site-packages/samcli/lib/build/app_builder.py", line 1003, in _parse_builder_response
response = json.loads(stdout_data)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None

An unexpected error was encountered while executing "sam build".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20JSONDecodeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20JSONDecodeError

The same issue reported by chandra 1 hour ago is here:     

Error: Expecting value: line 1 column 1 (char 0)
Traceback:
File "click/core.py", line 1078, in main
File "click/core.py", line 1688, in invoke
File "click/core.py", line 1434, in invoke
File "click/core.py", line 783, in invoke
File "samcli/cli/cli_config_file.py", line 347, in wrapper
File "click/decorators.py", line 92, in new_func
File "click/core.py", line 783, in invoke
File "samcli/lib/telemetry/metric.py", line 185, in wrapped
File "samcli/lib/telemetry/metric.py", line 150, in wrapped
File "samcli/lib/utils/version_checker.py", line 43, in wrapped
File "samcli/cli/main.py", line 95, in wrapper
File "samcli/commands/build/command.py", line 169, in cli
File "samcli/commands/build/command.py", line 258, in do_cli
File "samcli/commands/build/build_context.py", line 284, in run
File "samcli/lib/build/app_builder.py", line 226, in build
File "samcli/lib/build/build_strategy.py", line 416, in build
File "samcli/lib/build/build_strategy.py", line 83, in build
File "samcli/lib/build/build_strategy.py", line 422, in _build_functions
File "samcli/lib/build/build_strategy.py", line 438, in _run_builds_async
File "samcli/lib/utils/async_utils.py", line 137, in run_async
File "samcli/lib/utils/async_utils.py", line 96, in run_given_tasks_async
File "asyncio/base_events.py", line 654, in run_until_complete
File "samcli/lib/utils/async_utils.py", line 62, in _run_given_tasks_async
File "concurrent/futures/thread.py", line 58, in run
File "samcli/lib/build/build_strategy.py", line 449, in build_single_function_definition
File "samcli/lib/build/build_strategy.py", line 595, in build_single_function_definition
File "samcli/lib/build/build_strategy.py", line 303, in build_single_function_definition
File "samcli/lib/build/build_strategy.py", line 168, in build_single_function_definition
File "samcli/lib/build/app_builder.py", line 723, in _build_function
File "samcli/lib/build/app_builder.py", line 982, in _build_function_on_container
File "samcli/lib/build/app_builder.py", line 1003, in _parse_builder_response
File "json/init.py", line 346, in loads
File "json/decoder.py", line 337, in decode
File "json/decoder.py", line 355, in raw_decode

An unexpected error was encountered while executing "sam build".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20JSONDecodeError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20JSONDecodeError
Error: Process completed with exit code 1.


This unexpected error occurred while executing the sam build.

Here's the command we are using in the GitHub action workflow:
`sam build --template template.yaml --use-container`

_Originally posted by @chandrapratapsingh007 in https://github.com/aws/aws-sam-cli/issues/7092#issuecomment-2203284574_
            
@mildaniel
Copy link
Contributor

Hey @cmyers009, can you provide some more details to help us reproduce the issue? I tried reproducing using the Python3.11 Hello World template but was unable to.

It would be helpful if you could provide

  1. a template snippet with the minimal setup for reproduction
  2. the version of SAM CLI and Docker you are using

@mildaniel mildaniel added the blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. label Jul 2, 2024
@cmyers009
Copy link
Author

The error is not entirely reproducable. It happened one time, when there were no changes to the template or deployment file. We ran the same deployment again, and it built and deployed successfully.

Unfortunately, I can not share the template with you. It is not reproducable on my end, it just happens very rarely.

jobs:
  deploy-sam-application:
    runs-on: ubuntu-latest
    environment: development

    env:
      SAM_CLI_TELEMETRY: 0
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          submodules: 'recursive'

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      
      - name: Setup SAM
        uses: aws-actions/setup-sam@v2

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ vars.AWS_REGION }}

      - name: Build SAM application
        run: sam build --cached --use-container -t rest-api.yaml #--debug if you want to have more details on warnings.

@jysheng123
Copy link
Contributor

Apologies, but to be able to help determine the root cause/fix the issue, we need to be able to reproduce the error on our machines, if there is no example/steps to reproduce we can't help debug this issue. For now Ill close this issue, but if you are able to have an example that consistently fails, feel free to open another ticket

Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale.
Projects
None yet
Development

No branches or pull requests

3 participants