Problem
When issuing a runs POST request, the operation may fail with "unprocessable entity","detail":"invalid run parameters"
error.
Example:
badger@badger-C02FH0FHMD6R test % curl \
--request POST \
--header "Authorization: Bearer $ADMIN_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--data @run_payload.json \
https://alive-anemone.tf-support.hashicorpdemo.com/api/v2/runs
{"errors":[{"status":"422","title":"unprocessable entity","detail":"invalid run parameters"}]}%
Cause
If the configuration-versions is not yet in an uploaded status and is still uploading prior to issuing the runs POST request, this will return an unprocessable entity","detail":"invalid run parameters
error. This is because the configuration-versions specified in the run payload is not yet valid.
Solution
A GET request to the configuration-versions
endpoint for the workspace can confirm if the configuration-versions
status is "uploaded" prior to the runs POST request.
Example:
Configuration-versions POST Request
badger@badger-C02FH0FHMD6R test % curl \
--request POST \
--header "Authorization: Bearer $ADMIN_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--data @payload.json \
https://alive-anemone.tf-support.hashicorpdemo.com/api/v2/workspaces/ws-hsaGbUNEhhxstjmt/configuration-versions
{"data":{"id":"cv-ntv3HbhJqvFzamy7","type":"configuration-versions","attributes":{"auto-queue-runs":true,"error":null,"error-message":null,"source":"tfe-api","status":"pending","status-timestamps":{},"changed-files":[],"upload-url":"https://alive-anemone.tf-support.hashicorpdemo.com/_archivist/v1/object/dmF1bHQ6djE6aksvUGhmbVZUQ3BDMWJxeTA5YTNWU2lsU0ppTTZUd0xMMStjdEorSVNpQVRQbGJ6c3JzUVJ6ZHJ5VFVoQytNVUM4K2dZcnY2ZUk0eU5mQmVoclNjQzZOUFRDaU9Fb3JUVUlvYVlCVUZlVHZ0NGcwcXh2Mm1sL2dvcmpvYmRXbjExYjdJOFpiMEF2cWZPZ0RXakp2ZzhadUExcVk1QUs0RThTVXJzUyt4SVcrZ1E0cFlLUUwzcnQ0L3JSWlozN2d2c2pjV0syVjlTaHl5akhBeC9TeTNnbDRLU28zTG1tbVQ3WjFOa1VWTmdoVjNLVGNhMVBjaGxVTStJRTBhT05sSzU1YVM5b2JNNTNQZHFhYjJlOW9Hb3lLNFNlZkd5dzA9"},"relationships":{"ingress-attributes":{"data":null,"links":{"related":"/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/ingress-attributes"}}},"links":{"self":"/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7"}}}%
Configuration-versions GET Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request GET \
https://alive-anemone.tf-support.hashicorpdemo.com/api/v2/workspaces/ws-hsaGbUNEhhxstjmt/configuration-versions
{ "data": [ { "id": "cv-ntv3HbhJqvFzamy7", "type": "configuration-versions", "attributes": { "error": null, "error-message": null, "source": "gitlab", "speculative":false, "status": "uploaded", <---------- "status-timestamps": {} }, "relationships": { "ingress-attributes": { "data": { "id": "ia-i4MrTxmQXYxH2nYD", "type": "ingress-attributes" }, "links": { "related": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7/ingress-attributes" } } }, "links": { "self": "/api/v2/configuration-versions/cv-ntv3HbhJqvFzamy7" } } ] }
With the above response data, a subsequent runs POST request will not error because the configuration-versions status is "uploaded".
Additional Information
If you are unable to resolve the issue please submit a ticket via our support portal.