Skip to content

Portal: KeyValueMapField should not emit hidden input when empty #707

@alexluong

Description

@alexluong

Problem

KeyValueMapField always renders a hidden <input> with JSON.stringify() of its pairs. When there are no valid key-value pairs, this produces "{}" (empty JSON object), which the webhook destination backend validation rejects — it expects either a non-empty headers map or the field to be absent/empty string.

Currently both CreateDestination and DestinationSettings have band-aid fixes that convert "{}" to "" for custom_headers specifically. This is fragile and requires every consumer to handle the edge case.

Proposed fix

Fix KeyValueMapField at the source: don't render the hidden <input> when there are no valid pairs. This way the field is simply absent from the form data — no ambiguity between "" and "{}", and no band-aids needed in consumers.

Once the component is fixed, remove the custom_headers workarounds in:

  • CreateDestination.tsx
  • DestinationSettings.tsx

Files

  • internal/portal/src/common/KeyValueMapField/KeyValueMapField.tsx
  • internal/portal/src/scenes/CreateDestination/CreateDestination.tsx
  • internal/portal/src/scenes/Destination/DestinationSettings/DestinationSettings.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions