Skip to content

[BUG] Critical: UnicodeDecodeError when trying to launch on Windows #51

@DennisTraub

Description

@DennisTraub

Describe the bug
When running agentcore launch (CLI) or the Runtime object's launch() method (Python) on Windows, the application fails with a UnicodeDecodeError due to subprocess output being decoded using Windows' default 'charmap' codec instead of UTF-8. This occurs in the container runtime build process when calling Docker commands via subprocess.

The issue occurs because in utils/runtime/container.py, subprocess.Popen is called with text=True but without specifying encoding='utf-8'. On Windows, this causes Python to use the default 'charmap' codec (cp1252) which cannot handle certain UTF-8 bytes. The fix is to explicitly specify encoding='utf-8' in all subprocess calls that use text=True.

I submitted a PR with the fix: #52

To Reproduce
Steps to reproduce the behavior:

  1. Install bedrock-agentcore-starter-toolkit on Windows
  2. Configure an agent
  3. Run agentcore launch or call launch() on the Runtime object in Python
  4. See UnicodeDecodeError during Docker build process

Expected behavior
The launch process should complete successfully without encoding errors, properly handling UTF-8 output from subprocess calls.

Error Output
CLI:

$ agentcore launch
Launching Bedrock AgentCore (cloud mode)...

Launching Bedrock AgentCore agent 'mcp_server' to cloud
❌ 'charmap' codec can't decode byte 0x81 in position 14: character maps to <undefined>  

Python:

UnicodeDecodeError                        Traceback (most recent call last)

...

File ~\AppData\Roaming\Python\Python313\site-packages\bedrock_agentcore_starter_toolkit\notebook\runtime\bedrock_agentcore.py:130, in Runtime.launch(self, local, push_ecr, env_vars)
    127 if not self._config_path:
    128     raise ValueError("Must configure before launching. Call .configure() first.")
--> 130 result = launch_bedrock_agentcore(self._config_path, local=local, push_ecr_only=push_ecr, env_vars=env_vars)
    132 if result.mode == "cloud":
    133     log.info("Deployed to cloud: %s", result.agent_arn)

File ~\AppData\Roaming\Python\Python313\site-packages\bedrock_agentcore_starter_toolkit\operations\runtime\launch.py:58, in launch_bedrock_agentcore(config_path, agent_name, local, push_ecr_only, env_vars)
     55 tag = f"bedrock_agentcore-{bedrock_agentcore_name}:latest"
     57 # Step 1: Build Docker image
---> 58 success, output = runtime.build(build_dir, tag)
     59 if not success:
     60     error_lines = output[-10:] if len(output) > 10 else output

File ~\AppData\Roaming\Python\Python313\site-packages\bedrock_agentcore_starter_toolkit\utils\runtime\container.py:205, in ContainerRuntime.build(self, dockerfile_dir, tag, platform)
    202 cmd.extend(["--platform", build_platform])
...
File c:\Program Files\Python313\Lib\encodings\cp1252.py:23, in IncrementalDecoder.decode(self, input, final)
     22 def decode(self, input, final=False):
---> 23     return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 14: character maps to <undefined>

Environment:

  • OS: Windows 11
  • Python version: 3.13.2
  • Package version: 0.1.0
  • Installation method: any method

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruntimeRelated to agentcore runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions