otf icon indicating copy to clipboard operation
otf copied to clipboard

State doesn't handle special characters in outpout names

Open elijahnyp opened this issue 2 months ago • 0 comments

When using special characters in output names, such as thing@custom, the API returns 500 errors after a successful apply when hitting certain endpoints.

It appears to be endpoints where the state is marshaled via jsonapi.Marshal(). The fix would seem to be adding the marshal option to disable jsonapi name validation but I'm not sure if this is going to cause issues elsewhere in the API contract between the server and the agents.

This seems to be happening because the endpoints are including the outputs in json while the state is base64 encoded.

The behavior when this is hit is extremely confusing:

  • using OTF for state only works as expected
  • running plans on the OTF server works as expected
  • running plans on an agent fail with the server returning a 500
    • this 500 is only seen agent-side - even with debug set at level 9 the server reports successfully retrieving the state
  • terraform state pull and terraform state push work

My proposed fix is to add something like opts = append(opts, jsonapi.MarshalSetNameValidation(jsonapi.DisableValidation)) around line 33 in responder.go.

Happy to submit a PR if this seems like the right fix, but if it's easier to include it as part of something else I'd be equally happy.

elijahnyp avatar Dec 19 '25 15:12 elijahnyp