ValidationException action is invalid json string using boto3

0

Hi all,

I'm trying to create a quantum task using the boto client and I get a ValidationException "action is invalid json string".

I am creating a python string for the "action" that seems legal, but for some reason I keep getting this exception. The (very simple) string is:

{"braketSchemaHeader": {"name": "braket.ir.jaqcd.program", "version": "1"}, "results": [], "basis_rotation_instructions": [], "instructions": [{"type": "h", "target": 0}, {"type": "h", "target": 1}, {"type": "h", "target": 0}, ]}

I get no other more detailed information on the exception or validation.

Thanks in advance for your help
Best

fim
asked 3 years ago383 views
2 Answers
0

Hi all,

The original message is not showing the complete json action... I'll try to edit it to show the complete string.

But the answer is: the offending character is the last comma in the instructions. You can check that using json.loads(action_string) with and without the comma.

The next problem to solve was the "properties". The boto3 documentation is horrible in the description of the fields. In fact, no description at all.

Thanks
Best

fim
answered 3 years ago
0

Glad to hear that you were able to find the issue with action string!

Thanks for the feedback on the boto3 documentation! This is super helpful. I'm assuming you're referring to the documentation for the parameters here https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/braket.html#Braket.Client.create_quantum_task

We'll work on adding more details to boto3. Meanwhile you can look at the amazon-braket-schemas repository https://github.com/aws/amazon-braket-schemas-python/blob/main/src/braket/ir/jaqcd/program_v1.py which contains the specifications for this field.

We would also love to hear more about the other issues you encountered using Braket and learn more about what tools/details you think you would have found helpful in order to improve your experience. Please feel free to add in additional observations here and we'll try to incorporate those.

AWS
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions