Status code 422 on catalog deploy

OK, here’s a weird one, it doesn’t appear to match similar posts. I’ll start with the issue and provide system details after.

I have a catalog that item that fails (before creating services) with the following message;

msg=“stack:1st771 failed: Bad response statusCode [422]. Status [422 status code 422]. Body: [code=InvalidOption, fieldName=Image is required when selectorContainer is not passed in, baseType=error] from [http://localhost:8080/v2-beta/projects/1a341/services]”

Starting the stack appears to work, but because of the error automated deployments will be considered a failure.

Now the weird thing is if I copy and paste the compose file configuration from the UI (which is showing the above error) directly into a new stack again via the UI, it works without complaint.

Any suggestions on debug approach?

I’m unable to post the docker and rancher compose files due to client sensitivity.

System details;
Rancher 1.6.12
Rancher Agent 1.2.7
Orchestration Cattle
Docker 17.06 CE
OS Ubuntu 16.04

Never mind, worked it out.

For others experiencing something similar - this was caused by an attempt to conditionally remove a service from the docker compose file. Rancher was complaining about the unmatched service entry in the rancher compose configuration. The solution was to remove the entry from the rancher compose file - there were no settings there that weren’t already the default or overridden/ignored by Rancher. Rancher then creates what ever it requires on deploy.

Why it worked after the manual copy? Rancher had helpfully removed the rancher compose entry as part of the error process. But the error continued to be reported.