Skip to content

fix(Helpers): flagsmith.annotations emits duplicate keys when a custom annotation overrides a common one #543

Description

@germangarces

The flagsmith.annotations helper combines common.annotations with a resource's own annotations by printing both blocks one after the other. When the same key exists in both, the rendered output contains that key twice:

annotations:
    company.io/owner: platform         # from common.annotations
    company.io/owner: migrations-team   # from the resource

Duplicate keys are invalid YAML. Kubernetes and lenient parsers keep the last one, so applies usually work — but strict tools (kubeconform --strict, kubectl --strict, ArgoCD) reject it, and the manifest is misleading to read.

This affects every resource using the helper with the customAnnotations / commonValues form — services, ingresses, gateways.

Suggested fix

Merge the two maps into one before rendering (resource-specific key wins), instead of concatenating. A fresh-dict merge avoids mutating values:

merge (dict) $resourceAnnotations $commonAnnotations

How to reproduce

Set the same annotation key in both common.annotations and a resource's annotations, run helm template, observe the duplicate key.

Discovered while reviewing #542.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions