atmos icon indicating copy to clipboard operation
atmos copied to clipboard

a single ' causes atmos to error out when using !template tojson

Open minoseah629 opened this issue 9 months ago • 2 comments

Describe the Bug

have an atmos setup that uses !template toJson.

within my json, I have a single ' inside a specific json field.

Image

Expected Behavior

atmos should be able to handle the json field to have ' with no issue.

Image

Steps to Reproduce

in stack, use _defaults.yaml

settings:
  templates:
    settings:
      gomplate:
        timeout: 5
        datasources:
          vars_defaults:
            url: "../../Variables/defaults.json"

in top level overrides.yaml, include

vars: 
  bedrock_agent_configs: !template '{{ toJson (datasource "vars_merged_final").bedrock_agent_configs }}'

in enviornment level (dev), override.yaml:

settings:
  templates:
    settings:
      gomplate:
        timeout: 5
        datasources:
          vars_environment:
            url: ../../Variables/dev.json
          vars_merged_final:
            url: merge:vars_environment|vars_defaults

Screenshots

No response

Environment

OS: Window version 26100.3915 module - n/a terraform: 1.11.3

Additional Context

No response

minoseah629 avatar May 12 '25 21:05 minoseah629

apparently ’ works okay, while ' doesnt

minoseah629 avatar Jun 03 '25 19:06 minoseah629

In general, I would take every single opportunity to avoid using Go templating when you can. Go templating is an escape hatch, and the more complex the expression or the scenario, the harder it is to reconcile.

Seeing as you're reading in a JSON file, why not use one of our YAML functions instead? These are first-class YAML citizens.

Something like this.

vars: 
  bedrock_agent_configs: !include "../../Variables/defaults.json" .bedrock_agent_configs

osterman avatar Jul 11 '25 15:07 osterman