Skip to content

Array outputFormat duplicate keys are silently overwritten #45

Description

@MicroMilo

Summary

The backend accepts outputFormat as either an object map or an array of { key, type } rows. When the array form contains duplicate keys, normalizeOutputFormat collapses it into an object before validation, so the duplicate is silently overwritten.

Reproduction

validatePostScript({
  name: 'duplicate-output',
  content: 'Analyze {{summary}}.',
  outputFormat: [
    { key: '_chip_risk', type: 'string' },
    { key: '_chip_risk', type: 'number' },
  ],
})

This is accepted and normalized to the last value.

Workflow output formats have the same issue for non-terminal duplicate keys.

Expected behavior

Array-form output formats should reject duplicate keys before normalization.

Impact

API callers can submit ambiguous schemas that the frontend would reject, and the backend's duplicate-key validation does not catch them because the duplicate is already lost.

Suggested fix

Detect duplicate keys in array-form output formats before calling or immediately after parsing for normalization, then surface a 422 validation error for workflow and post-script validators.

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