getsops/sops · error

cannot use complex value in dotenv file; offending key %s

Error message

cannot use complex value in dotenv file; offending key %s

What it means

Error "cannot use complex value in dotenv file; offending key %s" thrown in getsops/sops.

Source

Thrown at stores/dotenv/store.go:93

// EmitEncryptedFile returns the encrypted file's bytes corresponding to a sops
// runtime object
func (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) {
	branches, err := stores.SerializeMetadata(in, stores.MetadataOpts{
		Flatten: stores.MetadataFlattenFull,
	})
	if err != nil {
		return nil, fmt.Errorf("Error marshaling metadata: %s", err)
	}
	return store.EmitPlainFile(branches)
}

// EmitPlainFile returns the plaintext file's bytes corresponding to a sops
// runtime object
func (store *Store) EmitPlainFile(in sops.TreeBranches) ([]byte, error) {
	buffer := bytes.Buffer{}
	for _, item := range in[0] {
		if stores.IsComplexValue(item.Value) {
			return nil, fmt.Errorf("cannot use complex value in dotenv file; offending key %s", item.Key)
		}
		var line string
		if comment, ok := item.Key.(sops.Comment); ok {
			line = fmt.Sprintf("#%s\n", comment.Value)
		} else {
			value, ok := item.Value.(string)
			if !ok {
				value = stores.ValToString(item.Value)
			} else {
				value = strings.ReplaceAll(value, "\n", "\\n")
			}

			line = fmt.Sprintf("%s=%s\n", item.Key, value)
		}
		buffer.WriteString(line)
	}
	return buffer.Bytes(), nil
}

View on GitHub (pinned to 13442bb981)

When it happens

Trigger: Thrown at stores/dotenv/store.go:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of getsops/sops@13442bb981 (2026-09-01). Data as JSON: /api/errors/02d17a235afff1eb. Report an issue: GitHub.