Auth0-deploy-cli v7.3.1: Bad Request: A draft must be in the 'built' state before it can be deployed


we’re using the latest version of auth0-deploy-cli (v.7.3.1) to automatically configure our auth0 tenant from our CI/CD pipeline.
We use the tenant.yaml method.
We have 4 custom actions that use the latest recommended runtime (Node 16).
We run auth0-deploy-cli each time there is a change in the Auth0 configuration and at least once a day, in the morning.
Most of the time everything runs fine, and the 4 actions are correctly built and deployed.

But sometimes, about once a week, one of the actions, not always the same, fails to deploy with an error messages similar to the following:

2021-11-05T07:40:51.061Z - info: [actions]: Waiting for build to complete {"id":"62e5287f-eb8e-4860-b510-d93dca039d04","name":"Send auth0_id"}
2021-11-05T07:42:15.971Z - error: Problem running command import during stage processChanges when processing type actions
2021-11-05T07:42:15.971Z - error: Problem Deploying actions {"id":"62e5287f-eb8e-4860-b510-d93dca039d04","name":"Send auth0_id"}
Bad Request: A draft must be in the 'built' state before it can be deployed.

Subsequent attempts fail, but not always with the same action.
There is a manual workaround which consists in looking at the action version history and reverting to another version.
But this defeats the purpose of CI/CD.

Does anyone have the same issue ?
Any idea about what could be checked in the tenant settings or environment to avoid this issue?

Thanks a lot !

P.S. For the sake of completeness, here are the logs corresponding to the successful action deployments for the same job execution as above.
2021-11-05T07:40:40.078Z - info: Updated [actions]: {"id":"28b31bd9-d37d-4cbe-b218-c7b1e503e115","name":"Force verification email"}
2021-11-05T07:40:40.350Z - info: Updated [actions]: {"id":"0aed505a-c85b-4118-9d39-7d99a6d08d71","name":"Enrich access token"}
2021-11-05T07:40:46.992Z - info: Updated [actions]: {"id":"9e4b7dbc-0631-47e2-a0b2-a91ac6d7c9ce","name":"Create tenant"}
2021-11-05T07:40:49.993Z - info: Updated [actions]: {"id":"62e5287f-eb8e-4860-b510-d93dca039d04","name":"Send auth0_id"}
2021-11-05T07:40:50.369Z - info: [actions]: Waiting for build to complete {"id":"9e4b7dbc-0631-47e2-a0b2-a91ac6d7c9ce","name":"Create tenant"}
2021-11-05T07:40:50.407Z - info: Deployed [actions]: {"id":"28b31bd9-d37d-4cbe-b218-c7b1e503e115","name":"Force verification email"}
2021-11-05T07:40:50.476Z - info: Deployed [actions]: {"id":"0aed505a-c85b-4118-9d39-7d99a6d08d71","name":"Enrich access token"}
2021-11-05T07:40:51.810Z - info: Deployed [actions]: {"id":"9e4b7dbc-0631-47e2-a0b2-a91ac6d7c9ce","name":"Create tenant"}

Hi @fgrenier,

Thanks for reaching out to the Auth0 Community!

I understand that you have been encountering issues with the Auth0-deploy-cli, specifically with the Bad Request error.

First, could you please clarify how long has this issue been affecting your CI/CD pipeline?

Next, could you please clarify if deploying the Actions with no changes after an export, result with the same intermitent errors?

And, could you also clarify if you have observed the same behavior when importing using the Directory structure?

Having looked closely at your errors, it appears that you have a Send auth0_id Action that is unable to be deployed. As a result, you observed the Bad Request error returned by the Management API.

A Bad Request error usually indicates that the object you’re working with has attributes which are not writable or are no longer available.

If this is the case, I recommend that you double-check your configuration to support the new object format used by Auth0.

However, if this issue persists intermitently even after verifying that everything is in the correct format, I would encourage you to open a Github Issue in the Auth0 Deploy CLI repo for further support.

Looking forward to your response.

Thank you.

Hi Rueben,
thanks for your answer.
We have been running this CI/CD job for several months without issues.
They started appearing a couple weeks ago.
We noticed a warning about the obsolete Node runtime (I think it was 12) so we upgraded all actions to Node 16 with no success.
Then we tried to update auth0-deploy-cli from 7.2.1 to 7.3.1.
At first it looked better, but we still have these intermittent errors.
I don’t think that we have a format issue or it would happen every time.
The Bad Request makes sense if the tool tries to deploy an action that is still building.
Is there a way to increase the time the tool waits for the action to build?
Thanks a lot

We’re experiencing the same problem, a lot. And when we then check the Auth Actions library, it says the actions are either building, or saved. Manually redeploying those actions also doesn’t help.

Hi @fgrenier,

Thank you for your response and clarification.

I agree with your observations that your format shouldn’t be an issue given that the import jobs managed to work and fail intermittently.

If you are unsuccessful in migrating your Action from Node 12 to Node 16 using the Auth0-deploy-cli, were you able to find any workarounds? If not, I recommend that you use the Management API Update an Action endpoint and set the runtime to node16:


Unfortunately, there isn’t any way to increase the time the tool waits for the Action to build.

Hoped this helps!

Please let me know if there is anything else I can do to help.

Thank you.

Hi Rueben,
sorry if I wasn’t clear. We didn’t have any issue migrating to Node 16.
I mentioned this to say that we are up to date now.
The issue is only related to custom actions that are blocked in the “Building” or “Saved” status and that cause the auth0-deploy-cli tool to fail.
I don’t think that the issue is coming from the tool itself because these custom actions never go to the deployed state even when we do a manual action.
Please let me know if I can provide any more detail to reproduce this issue, which is impacting our workflow.
Thanks a lot

Hi Rueben,

I have some new information.

This morning the CI/CD job passed.
However, when I look at the custom actions in the UI, one of them is in the “Built” state, and not deployed.

Here are the corresponding auth0-deploy-cli logs:
2021-11-10T07:15:32.254Z - info: [actions]: Waiting for build to complete {"id":"62e5287f-eb8e-4860-b510-d93dca039d04","name":"Send auth0_id"} 2021-11-10T07:15:37.628Z - info: Deployed [actions]: {"id":"62e5287f-eb8e-4860-b510-d93dca039d04","name":"Send auth0_id"} ``

As you can see, auth0-deploy-cli indicates that the action was deployed.
But it’s not.
See attached screenshot.

Then, If I go to the actions detail and I deploy the action manually, it gets deployed.
However, If I don’t do this manual action and I let the job run again, that’s when we run into a deadlock.

As a conclusion, sometimes, Auth0 fails to deploy a custom action but incorrectly reports that it was deployed to the auth0-deploy-cli tool.

I hope that this will be sufficient information to reproduce this issue and fix it.
Please let me know if I can help any further.

Many thanks

1 Like