Skip to content

safely report error in credential_process with stdout cannot be decoded - #100

Merged
onno-vos-dev merged 2 commits into
aws-beam:masterfrom
kylewhite21:feature/safe-decode-credential-process
Jul 21, 2026
Merged

safely report error in credential_process with stdout cannot be decoded#100
onno-vos-dev merged 2 commits into
aws-beam:masterfrom
kylewhite21:feature/safe-decode-credential-process

Conversation

@kylewhite21

Copy link
Copy Markdown
Contributor

I am using credential_process to get credentials, but if the stdout is not an encoded map, the decode will raise and cause a cryptic failure:

19:02:51.792 pid=<0.229.0> module=aws_credentials [info] aws_credentials ignoring exception :error::badarg ([
  {:jsx_decoder, :value, 4,
   [file: ~c"path/deps/jsx/src/jsx_decoder.erl", line: 234]},
  {:aws_credentials_file, :read_from_profile, 2,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials_file.erl",
     line: 148
   ]},
  {:aws_credentials_file, :parse_credentials_file, 2,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials_file.erl",
     line: 108
   ]},
  {:aws_credentials_file, :fetch, 1,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials_file.erl",
     line: 45
   ]},
  {:aws_credentials_provider, :evaluate_providers, 3,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials_provider.erl",
     line: 77
   ]},
  {:aws_credentials, :fetch_credentials, 1,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials.erl",
     line: 177
   ]},
  {:aws_credentials, :init, 1,
   [
     file: ~c"path/deps/aws_credentials/src/aws_credentials.erl",
     line: 123
   ]},
  {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 2229]}
])

This PR adds a try/catch to that input, and will show the input if the decode fails:

19:22:36.859 pid=<0.229.0> module=aws_credentials [error] Provider :aws_credentials_env reports {:error, :environment_credentials_unavailable}
19:22:36.861 pid=<0.229.0> module=aws_credentials [error] Provider :aws_credentials_file reports {:error, {:invalid_credential_process_output, ~c"Touch your YubiKey..."}}

@onno-vos-dev

Copy link
Copy Markdown
Member

Hi @kylewhite21 thank you for your contribution 💪 I'll have a look in the morning. 👍 I've started the GitHub Actions at least in the meantime 👍

@kylewhite21

Copy link
Copy Markdown
Contributor Author

ah shoot, failed on depth. I can fix that (later)

@onno-vos-dev

Copy link
Copy Markdown
Member

@kylewhite21 Please have a look at the build. Elvis is not dancing today 🕺😄

@kylewhite21

Copy link
Copy Markdown
Contributor Author

@onno-vos-dev ok, should be good now

@onno-vos-dev
onno-vos-dev merged commit eed6d0e into aws-beam:master Jul 21, 2026
6 checks passed
@onno-vos-dev

Copy link
Copy Markdown
Member

@kylewhite21 Sorry for the delay 👍 Release just went out as 1.0.6

Thanks for the fix! ❤️

@kylewhite21
kylewhite21 deleted the feature/safe-decode-credential-process branch July 24, 2026 15:44
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