{"record":{"id":"e88d13be705aece6","repo":"jackwener/OpenCLI","slug":"repeat-conflicts-with-the-prompt-structuredre","errorCode":null,"errorMessage":"--repeat conflicts with the prompt (${structuredRepeat} vs ${rawRepeat})","messagePattern":"--repeat conflicts with the prompt \\((.+?) vs (.+?)\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/capabilities.js","lineNumber":242,"sourceCode":"    throw new ArgumentError(`--quality is not supported by ${selectedModel}`);\n  }\n  if (quality) {\n    const normalizedQuality = Number(quality);\n    if (![0.25, 0.5, 1].includes(normalizedQuality)) {\n      throw new ArgumentError('--quality must be 0.25, 0.5, or 1 for supported legacy models');\n    }\n  }\n\n  const rawRepeat = promptParamValue(prompt, ['r', 'repeat']);\n  const structuredRepeat = args.repeat == null || args.repeat === '' ? null : Number(args.repeat);\n  if (structuredRepeat != null && (!Number.isInteger(structuredRepeat) || structuredRepeat < 1)) {\n    throw new ArgumentError('--repeat must be a positive integer');\n  }\n  if (rawRepeat != null && (!/^\\d+$/.test(rawRepeat) || Number(rawRepeat) < 1)) {\n    throw new ArgumentError('--repeat in the prompt must be a positive integer');\n  }\n  if (structuredRepeat != null && rawRepeat != null && structuredRepeat !== Number(rawRepeat)) {\n    throw new ArgumentError(`--repeat conflicts with the prompt (${structuredRepeat} vs ${rawRepeat})`);\n  }\n  const repeat = structuredRepeat ?? (rawRepeat == null ? 1 : Number(rawRepeat));\n  if (repeat > capabilities.repeatLimit) {\n    throw new ArgumentError(`${capabilities.plan || 'current'} plan allows at most ${capabilities.repeatLimit} repeat/permutation jobs`);\n  }\n\n  let perJobMinutes = hasOmniReference || promptHasFlag(prompt, ['oref'])\n    ? GPU_COST_MINUTES.omni\n    : resolution === 'hd'\n      ? GPU_COST_MINUTES.imageHd\n      : GPU_COST_MINUTES.imageSd;\n  if (promptHasFlag(prompt, ['draft'])) perJobMinutes /= 2;\n  // The current web service charged a full SD batch for a live V6 --q 0.5\n  // job. Keep the cost guard conservative instead of applying historical\n  // quality discounts that are no longer reflected in account credits.\n  if (speed === 'turbo') perJobMinutes *= 2;\n  // Relax jobs do not consume the subscription's Fast GPU minute balance.\n  // Keep the guard and reported estimate aligned with the quota it protects.","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/capabilities.js#L224-L260","documentation":"When both the prompt text (--r/--repeat flag) and the structured args.repeat option are present, resolveGenerationPlan requires them to agree. This error is thrown if the two values differ, e.g. prompt '--r 2' with args.repeat 4, to avoid ambiguity about how many jobs to run.","triggerScenarios":"Calling generate/plan with a prompt containing '--r 2' while also passing { repeat: 4 } (or any numeric args.repeat not equal to Number(promptFlag)). Both must be present and unequal.","commonSituations":"A wrapper/template injects --repeat into the prompt while the caller also sets args.repeat; an old hardcoded prompt string kept after switching to the structured option; copy-pasted prompts that still carry flags.","solutions":["Make both values identical, or delete one: keep either the prompt flag or args.repeat, not both.","Strip --r/--repeat (and other flags) from the prompt string and rely solely on args.repeat.","If the prompt is built dynamically, remove its repeat flag programmatically before merging with structured options.","If conflict is intentional, resolve it in your own code first by choosing one value."],"exampleFix":"// before\nawait midjourney.generate({ prompt: 'a cat --r 2', repeat: 4 });\n// after\nawait midjourney.generate({ prompt: 'a cat', repeat: 4 });","handlingStrategy":"validation","validationCode":"function repeatsAgree(prompt, argsRepeat) {\n  const m = /(?:^|\\s)--(?:r|repeat)(?:[= ]([^\\s]+))?/.exec(prompt);\n  const raw = m ? m[1] : null;\n  if (argsRepeat == null || raw == null) return true;\n  return Number(argsRepeat) === Number(raw);\n}\nif (!repeatsAgree(prompt, args.repeat)) throw new Error('--repeat in args conflicts with prompt');","typeGuard":"function hasNoPromptRepeatFlag(prompt) {\n  return !/(?:^|\\s)--(?:r|repeat)(?:[= ]|$)/.test(prompt);\n}","tryCatchPattern":"try {\n  return await plan(args);\n} catch (err) {\n  if (err instanceof ArgumentError && err.message.startsWith('--repeat conflicts with the prompt')) {\n    // keep only one source of truth\n    const structured = args.repeat != null;\n    const cleanPrompt = structured ? prompt.replace(/\\s*--(?:r|repeat)(?:[= ]\\S+)?/, '') : prompt;\n    return plan({ ...args, prompt: cleanPrompt });\n  }\n  throw err;\n}","preventionTips":["Pick one source of truth for repeat: structured args only; strip flags from prompts.","When templates inject flags into prompts, diff them against structured options before sending.","Centralize prompt-building so repeat is never appended in two places.","Log the final prompt and args during development to spot duplicated flags."],"tags":["cli","validation","argument-error","conflicting-options"],"backgroundTag":"conflicting-parameter-values","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}