{"record":{"id":"371e2f56b7830e57","repo":"ipfs/kubo","slug":"unable-to-use-q-deprecated-and-a-custom-q-at-t","errorCode":null,"errorMessage":"unable to use %q (deprecated) and a custom %q at the same time","messagePattern":"unable to use %q \\(deprecated\\) and a custom %q at the same time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/block.go","lineNumber":215,"sourceCode":"\t\t}\n\n\t\tmhtval, ok := mh.Names[mhtype]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unrecognized multihash function: %s\", mhtype)\n\t\t}\n\n\t\tmhlen, ok := req.Options[mhlenOptionName].(int)\n\t\tif !ok {\n\t\t\treturn errors.New(\"missing option \\\"mhlen\\\"\")\n\t\t}\n\n\t\tcidCodec, _ := req.Options[blockCidCodecOptionName].(string)\n\t\tformat, _ := req.Options[blockFormatOptionName].(string) // deprecated\n\n\t\t// use of legacy 'format' needs to suppress 'cid-codec'\n\t\tif format != \"\" {\n\t\t\tif cidCodec != \"\" && cidCodec != \"raw\" {\n\t\t\t\treturn fmt.Errorf(\"unable to use %q (deprecated) and a custom %q at the same time\", blockFormatOptionName, blockCidCodecOptionName)\n\t\t\t}\n\t\t\tcidCodec = \"\" // makes it no-op\n\t\t}\n\n\t\tpin, _ := req.Options[pinOptionName].(bool)\n\n\t\tit := req.Files.Entries()\n\t\tfor it.Next() {\n\t\t\tfile := files.FileFromEntry(it)\n\t\t\tif file == nil {\n\t\t\t\treturn errors.New(\"expected a file\")\n\t\t\t}\n\n\t\t\tp, err := api.Block().Put(req.Context, file,\n\t\t\t\toptions.Block.Hash(mhtval, mhlen),\n\t\t\t\toptions.Block.CidCodec(cidCodec),\n\t\t\t\toptions.Block.Format(format),\n\t\t\t\toptions.Block.Pin(pin))","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/block.go#L197-L233","documentation":"`ipfs block put` accepts the legacy, deprecated --format flag and the newer --cid-codec flag. Passing both simultaneously is ambiguous: --format suppresses cid-codec handling for legacy CIDv0 output. A custom (non-raw) --cid-codec together with --format cannot be reconciled, so the command refuses the combination.","triggerScenarios":"Run `ipfs block put --format=v0 --cid-codec=dag-pb data.bin` (or any cid-codec other than the default 'raw') — the format != \"\" branch sees cidCodec not in {\"\", \"raw\"} and errors.","commonSituations":"Older scripts using --format=v0 updated to also set --cid-codec; users migrating flags and leaving both in place; copy-pasted command lines from different documentation versions.","solutions":["Drop --format and use only --cid-codec for new code","If legacy CIDv0 output is required, use only --format=v0 and remove --cid-codec (or leave it at default 'raw')","Update scripts: --format is deprecated and will eventually be removed"],"exampleFix":"// before\nipfs block put --format=v0 --cid-codec=dag-pb data.bin\n// after\nipfs block put --cid-codec=dag-pb data.bin","handlingStrategy":"validation","validationCode":"// shell: reject scripts that set both flags\nif [ -n \"$FORMAT\" ] && [ -n \"$CIDCODEC\" ] && [ \"$CIDCODEC\" != \"raw\" ]; then\n  echo \"use --cid-codec only; --format is deprecated\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Migrate all scripts to --cid-codec and delete --format usages","Keep --format=v0 only in legacy shims that never set --cid-codec","Audit flag construction helpers for stale defaults that inject --format"],"tags":["cli","block-put","deprecated-flag","conflicting-options"],"backgroundTag":"conflicting-flag-combination","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}