Yeachan-Heo/oh-my-codex · error

${path} must not contain duplicate values: ${value}

Error message

${path} must not contain duplicate values: ${value}

What it means

assertNoDuplicateValues rejects selected_values arrays containing the same value more than once. Multi-select answers must contain distinct option values; duplicates indicate a client bug or double-toggle when assembling the answer.

Source

Thrown at src/question/state.ts:306

      if (currentOwner.trim() === ownerToken) {
        await rm(lockDir, { recursive: true, force: true });
      }
    } catch {
    }
  }
}

function validateStringArray(value: unknown, path: string): string[] {
  if (!Array.isArray(value) || !value.every((item) => typeof item === 'string' && item.trim().length > 0)) {
    throw new Error(`${path} must be a non-empty string array`);
  }
  return value;
}

function assertNoDuplicateValues(values: string[], path: string): void {
  const seen = new Set<string>();
  for (const value of values) {
    if (seen.has(value)) throw new Error(`${path} must not contain duplicate values: ${value}`);
    seen.add(value);
  }
}

function expectedSelectedLabelsForValues(
  question: NormalizedQuestionItem,
  selectedValues: string[],
  otherText: string | undefined,
): string[] {
  const optionLabelsByValue = new Map(question.options.map((option) => [option.value, option.label]));
  return selectedValues.map((value) => {
    const optionLabel = optionLabelsByValue.get(value);
    if (optionLabel) return optionLabel;
    if (question.allow_other && otherText && value === otherText) return question.other_label;
    throw new Error(`selected value is not in the option schema: ${value}`);
  });
}

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Dedupe before submit: [...new Set(selected_values)]
  2. Fix the toggle handler to remove a value when it is already selected
  3. Add a unit test asserting deduped output from the selection store

Example fix

// before
answer.selected_values = [...currentSelections, newlyToggled];
// after
const set = new Set(currentSelections);
set.has(newlyToggled) ? set.delete(newlyToggled) : set.add(newlyToggled);
answer.selected_values = [...set];
Defensive patterns

Strategy: validation

Validate before calling

const deduped = [...new Set(answer.selected_values)];
if (deduped.length !== answer.selected_values.length) answer.selected_values = deduped;

Type guard

function hasNoDuplicates(values: string[]): boolean { return new Set(values).size === values.length; }

Try / catch

try { await submit(p, answers); } catch (e) { if (/must not contain duplicate values/.test((e as Error).message)) { answers[i].selected_values = [...new Set(answers[i].selected_values)]; return submit(p, answers); } throw e; }

Prevention

When it happens

Trigger: Submitting a multi answer whose selected_values contains the same option twice, e.g. ['a','b','a']; commonly from concatenating selections without deduping.

Common situations: Merging selected arrays from multiple UI components; toggle handlers that push instead of add/remove; replay/retry logic appending already-present values.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/69745d378eea0359. Report an issue: GitHub.