{"record":{"id":"3137bd9df9517400","repo":"coleam00/Archon","slug":"invalid-container-memorymb-string-memorymb","errorCode":null,"errorMessage":"Invalid container.memoryMb '${String(memoryMb)}' — must be a positive integer (MiB).","messagePattern":"Invalid container\\.memoryMb '(.+?)' — must be a positive integer \\(MiB\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":399,"sourceCode":" * untrusted at runtime despite their static types — validate them here. In\n * particular `network` must be `bridge`/`none`: a stray `host` would otherwise\n * flow straight to `docker run --network host` and drop the network isolation.\n */\nexport function resolveContainerBackendConfig(\n  cfg: { image?: string; network?: string; memoryMb?: number; pidsLimit?: number } | undefined\n): ContainerBackendConfig {\n  const network = cfg?.network;\n  if (network !== undefined && network !== 'bridge' && network !== 'none') {\n    throw new Error(\n      `Invalid container.network '${network}' in .archon/config.yaml — must be ` +\n        \"'bridge' or 'none'. Host networking is not allowed for container isolation.\"\n    );\n  }\n  // Positive INTEGERS — `docker run --memory`/`--pids-limit` reject fractions,\n  // and Number.isFinite alone would let `512.5` through to a runtime docker error.\n  const memoryMb = cfg?.memoryMb;\n  if (memoryMb !== undefined && (!Number.isInteger(memoryMb) || memoryMb <= 0)) {\n    throw new Error(\n      `Invalid container.memoryMb '${String(memoryMb)}' — must be a positive integer (MiB).`\n    );\n  }\n  const pidsLimit = cfg?.pidsLimit;\n  if (pidsLimit !== undefined && (!Number.isInteger(pidsLimit) || pidsLimit <= 0)) {\n    throw new Error(\n      `Invalid container.pidsLimit '${String(pidsLimit)}' — must be a positive integer.`\n    );\n  }\n  return {\n    image: cfg?.image?.trim() || DEFAULT_RUNNER_IMAGE,\n    network: network ?? 'bridge',\n    memoryMb: memoryMb ?? 4096,\n    pidsLimit: pidsLimit ?? 512,\n  };\n}\n\n/**","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L381-L417","documentation":"resolveContainerBackendConfig() requires container.memoryMb from .archon/config.yaml to be a positive integer when present. `docker run --memory` rejects fractional or non-positive values, so the CLI validates strictly (Number.isInteger and > 0) and fails fast with this error instead of surfacing a runtime docker error.","triggerScenarios":"container.memoryMb set to a float (e.g. 512.5), zero, a negative number, or a non-numeric YAML scalar (string like '512m') passed to resolveContainerBackendConfig during workflow container setup.","commonSituations":"Copying a docker-style memory string ('512m', '1g') into the config; YAML unquoted strings staying strings; hand-tuning memory and typing a decimal; misreading the unit (the value is MiB, an integer).","solutions":["Set `container.memoryMb` to a positive whole number of MiB, e.g. `memoryMb: 512`.","Quote nothing and avoid units: use 1024 for 1 GiB, not '1g'.","Remove the key to accept the backend default."],"exampleFix":"// .archon/config.yaml (before)\ncontainer:\n  memoryMb: 512.5\n// after\ncontainer:\n  memoryMb: 512","handlingStrategy":"validation","validationCode":"const m = cfg?.container?.memoryMb;\nif (m !== undefined && (!Number.isInteger(m) || m <= 0)) {\n  throw new Error(`container.memoryMb must be a positive integer MiB value, got: ${String(m)}`);\n}","typeGuard":"function isPositiveInteger(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0;\n}","tryCatchPattern":"try {\n  await runWorkflow(name, opts);\n} catch (e) {\n  if (String((e as Error).message).includes('Invalid container.memoryMb')) {\n    console.error('Set container.memoryMb to a whole MiB number, e.g. memoryMb: 512.');\n  }\n}","preventionTips":["Remember the unit is MiB as a plain integer — no '512m'/'1g' docker strings.","Convert: 1 GiB = 1024, 2 GiB = 2048.","Avoid floats when tuning memory; round to whole MiB."],"tags":["configuration","validation","docker","container"],"backgroundTag":"invalid-config-value","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}