Skip to content

Fix panic when a YAML config has a non-string map key - #5259

Open
RaphaelFakhri wants to merge 1 commit into
superfly:masterfrom
RaphaelFakhri:fix-yaml-config-non-string-keys
Open

RaphaelFakhri wants to merge 1 commit into
superfly:masterfrom
RaphaelFakhri:fix-yaml-config-non-string-keys

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Change Summary

What and Why: stringifyYAMLMapKeys converts the map[any]any values that the YAML decoder returns for maps with non-string keys into map[string]any. It asserts each key is a string, so a config such as env: {1: one} or a true: key panics with interface conversion: interface {} is int, not string in LoadConfig and LoadConfigAsMap.

How: Format the key with fmt.Sprint instead of asserting its type, so 1 becomes "1", which matches how TOML and JSON configs treat keys. Adds a test that loads and strictly maps a YAML config with an integer key and a boolean key.

Related to: none


Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

Fixes #5258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading a YAML app config with a non-string map key panics

1 participant