Aws-cli: Unable to retrieve a job output if job ID starts with a dash

Created on 28 Jun 2015  路  5Comments  路  Source: aws/aws-cli

If, as a result of a "initiate-job" the job ID starts with a dash it seems to be impossible to retrieve that job results:

aws glacier get-job-output --vault-name vaultname --account-id - --job-id -job-id-with-a-leading-dash
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --job-id: expected one argument

For "describe-job" there is a reasonable workaround (described in issue #1319):

aws glacier describe-job --vault-name vaultname --account-id - --cli-input-json '{"jobId":"-job-id-with-a-leading-dash"}'

But no such workaround exists for "get-job-output". If it is hard to properly fix this, then maybe at least a cli-input-json support can be added for "get-job-output"?

Most helpful comment

This Issue is not solved and should be reopened I think. I still have the same problem and no way to get the job output. I used the jobID from attached joblist.json.txt and double checked the JobId, but the workaround with '-' syntax doesn't work with get-job-output command:
aws glacier get-job-output --account-id - --vault-name test-sylvain-couhault --job-id '-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O' output.json

An error occurred (ResourceNotFoundException) when calling the GetJobOutput operation: The job ID was not found: '-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O'

All 5 comments

You can pass the --job-id argument in using --job-id='-job-id-with...'. You can use this type of argument syntax for a single argument or any argument:

aws glacier describe-job --vault-name='vaultname' --account-id='-' --job-id='-job-id-with-a-leading-dash'

Great engineering. I am overwhelmed by this beauty and genius. Thank you, whoever thought it was a good idea to allow hyphens in the ids to begin with.

And no Amazon. Do not change this. It might break... ahem... nothing? This is something that you can change and nobody will ever have an issue.

Thanks to @mtdowling and @amaltsev for running through this stupidity before me.

Further more: aws-cli is so beautifully parsing the strings from the bash in its own peculiar way, that escaping the hyphen with the usual hacks is impossible. Well done!

This Issue is not solved and should be reopened I think. I still have the same problem and no way to get the job output. I used the jobID from attached joblist.json.txt and double checked the JobId, but the workaround with '-' syntax doesn't work with get-job-output command:
aws glacier get-job-output --account-id - --vault-name test-sylvain-couhault --job-id '-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O' output.json

An error occurred (ResourceNotFoundException) when calling the GetJobOutput operation: The job ID was not found: '-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O'

@bobilibop Try matching the example shown by @mtdowling. That is, instead of your command:

aws glacier get-job-output --account-id - --vault-name test-sylvain-couhault --job-id '-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O' output.json

use an = between the argument (--job-id) and the argument's value (so it's --job-id='$JOB_ID_HERE'), like this:

aws glacier get-job-output --account-id - --vault-name test-sylvain-couhault --job-id='-MSbDtRA0yvqadVEoAN462dXuoorq7Ms8xo1rUfqD-QM9pnqgNO07yEwquxVf9iimmpnTv3ecIbiSp9OBxtx_FtyIc5O' output.json

One of my scripts was failing and I traced the issue down to using the aws CLI in this manner. I think this is an obvious usability mistake on Amazon's part and could (should!) be fixed with something as simple as a note about this fact in literally any of the many pages of documentation about the AWS CLI I read over the past several days to track this bug in my scripts down. I.e., this can be fixed without code, Amazon, you just need to tell people what you implemented and how, please.

this pattern worked for me, equal sign with no single/double quotes:
--job-id=-FDRuiJXslObrKP

Was this page helpful?
0 / 5 - 0 ratings