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

Bug: sam build - JSONDecodeError #7092

Open
JoshLinneburg opened this issue May 22, 2024 · 5 comments
Open

Bug: sam build - JSONDecodeError #7092

JoshLinneburg opened this issue May 22, 2024 · 5 comments
Labels
area/build sam build command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale.

Comments

@JoshLinneburg
Copy link

JoshLinneburg commented May 22, 2024

Description:

I am building and deploying with SAM inside a Github Actions runner and occasionally get an error on the sam build command.

Steps to reproduce:

The exact command that I'm running is sam build --template ${SAM_TEMPLATE} --use-container, the error output is below. This happens maybe once out of every 8-10 deployments, I have not been able to consistently reproduce the error.

It seems to be more prevalent when I am deploying SAM applications that have more resources in the template.yaml but that's purely anecdotal. I have never received this error when running sam build on either of my local machines; one of these is Windows 10 and the other is running Ubuntu 22.04.4 LTS. The Github runner also appears to be running that same version of Ubuntu.

Observed result:

SAM builds all of my resources but after building the final resource, instead of a "Build Succeeded" message I receive this error:

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".

Expected result:

The command should run successfully.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 22.04.4 LTS
  2. sam --version: 1.117.0
  3. AWS region: us-east-2

I can add the output of sam --info to this Issue as well.

# Paste the output of `sam --info` here

Add --debug flag to command you are running

@JoshLinneburg JoshLinneburg added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label May 22, 2024
@lucashuy
Copy link
Contributor

Thanks for opening this issue, just want to confirm, is the SAM CLI being used the one that is provided in the runner, or is it a manual installation that you are using? Additionally, would it be possible to post more of the logs of the function that failed to build using the --debug flag? It might be difficult to capture this since as you mentioned, it's not consistent behaviour.

Just to poke at the command/template a bit, would it be possible to build within a container environment (ie. --use-container)?

@lucashuy lucashuy added area/build sam build command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels May 23, 2024
@chandrapratapsingh007
Copy link

I encountered the same issue:

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](https://github.com/CloudBoltSoftware/mira-deployment-orchestration/actions/runs/9757836085/job/26931087142#step:32:422), 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

@cmyers009
Copy link

also encountered same issue today.

@toddjcrane
Copy link

also experienced today. Build file is that which was generated by SAM pipelines.

@danjhd
Copy link

danjhd commented Feb 13, 2025

I am experiencing this problem and can re-produce it every time. Steps:

  1. Create new EC2 instance using AL2023 and an x86 arch (t2.micro).
  2. Install docker using the guide for linux here.
  3. Install sam cli using the linux guide here version installed 1.133.0
  4. Use sam init to create a new arm64 application sam init -a arm64 - Accept all defaults (python13/zip)
  5. Run sam build -u - FAILS

Running this exact same process on an arm64 EC2 (t4g) works. So it appears the problem is to do with mis-matching archs. I have been able to do this in the past so has anything changed to affect support of "cross arch"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build sam build command 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

6 participants