aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Bug: sam sync - TypeError

Open Eazash opened this issue 2 months ago • 2 comments

Description:

When running sam sync --stack-name <some-stack> --no-watch --save-params the following error comes up and the stack update fails

Error: can't subtract offset-naive and offset-aware datetimes
Traceback:
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/cli/cli_config_file.py", line 366, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/telemetry/metric.py", line 190, in wrapped
    raise exception  # pylint: disable=raising-bad-type
    ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/telemetry/metric.py", line 155, in wrapped
    return_value = func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/telemetry/event.py", line 382, in wrapped
    raise exception
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/telemetry/event.py", line 374, in wrapped
    return_value = func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/cli_validation/image_repository_validation.py", line 111, in wrapped
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/telemetry/metric.py", line 109, in wrapped
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/utils/version_checker.py", line 43, in wrapped
    actual_result = func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/cli/main.py", line 95, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/_utils/cdk_support_decorators.py", line 40, in wrapped
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/_utils/command_exception_handler.py", line 89, in wrapper_command_exception_handler
    raise ex
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/_utils/command_exception_handler.py", line 69, in wrapper_command_exception_handler
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/sync/command.py", line 229, in cli
    do_cli(
    ~~~~~~^
        template_file,
        ^^^^^^^^^^^^^^
    ...<28 lines>...
        watch_exclude,
        ^^^^^^^^^^^^^^
    )  # pragma: no cover
    ^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/sync/command.py", line 432, in do_cli
    infra_sync_result = execute_infra_contexts(
        build_context, package_context, deploy_context, sync_context
    )
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/commands/sync/command.py", line 475, in execute_infra_contexts
    return infra_sync_executor.execute_infra_sync(first_sync=True)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/aws-sam-cli/1.145.2/libexec/lib/python3.14/site-packages/samcli/lib/sync/infra_sync_executor.py", line 176, in execute_infra_sync
    days_since_last_infra_sync = (current_time - last_infra_sync_time).days
                                  ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

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

Steps to reproduce:

Run sam sync --stack-name <some-stack> --no-watch --save-params.

Observed result:

See description above

Expected result:

A stack update

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

{
  "version": "1.145.2",
  "system": {
    "python": "3.14.0",
    "os": "macOS-15.6.1-arm64-arm-64bit-Mach-O"
  },
  "additional_dependencies": {
    "container_engine": "Docker(v28.5.1)",
    "aws_cdk": "Not available",
    "terraform": "1.13.3"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_PACKAGE_PERFORMANCE",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Eazash avatar Oct 24 '25 08:10 Eazash

I'm seeing the same error, on a SAM installed using the latest aws-sam-cli-macos-arm64.pkg from the website (rather than brew).

Edit: I had to downgrade to 1.144.0 to avoid this error

swiftcoder avatar Oct 29 '25 13:10 swiftcoder

Yep similar issue on latest version: 1.145.2 from: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html Ubuntu Linux. Downgrading now.

Error: can't subtract offset-naive and offset-aware datetimes Traceback: File "click/core.py", line 1082, in main File "click/core.py", line 1697, in invoke File "click/core.py", line 1443, in invoke File "click/core.py", line 788, in invoke File "samcli/cli/cli_config_file.py", line 366, in wrapper File "click/decorators.py", line 92, in new_func File "click/core.py", line 788, in invoke File "samcli/lib/telemetry/metric.py", line 190, in wrapped File "samcli/lib/telemetry/metric.py", line 155, in wrapped File "samcli/lib/telemetry/event.py", line 382, in wrapped File "samcli/lib/telemetry/event.py", line 374, in wrapped File "samcli/lib/cli_validation/image_repository_validation.py", line 111, in wrapped File "samcli/lib/telemetry/metric.py", line 109, 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/_utils/cdk_support_decorators.py", line 40, in wrapped File "samcli/commands/_utils/command_exception_handler.py", line 89, in wrapper_command_exception_handler File "samcli/commands/_utils/command_exception_handler.py", line 69, in wrapper_command_exception_handler File "samcli/commands/sync/command.py", line 229, in cli File "samcli/commands/sync/command.py", line 432, in do_cli File "samcli/commands/sync/command.py", line 475, in execute_infra_contexts File "samcli/lib/sync/infra_sync_executor.py", line 176, in execute_infra_sync

An unexpected error was encountered while executing "sam sync".

Leigh-M avatar Nov 04 '25 15:11 Leigh-M