{"record":{"id":"29a46f0d38f30465","repo":"puppetlabs/puppet","slug":"unknown-option-sym","errorCode":null,"errorMessage":"unknown option '%{sym}'","messagePattern":"unknown option '%(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/command_line/trollop.rb","lineNumber":277,"sourceCode":"      @specs[name] = opts\n      @order << [:opt, name]\n    end\n\n    ## Sets the version string. If set, the user can request the version\n    ## on the commandline. Should probably be of the form \"<program name>\n    ## <version number>\".\n    def version s = nil; @version = s if s; @version end\n\n    ## Adds text to the help display. Can be interspersed with calls to\n    ## #opt to build a multi-section help page.\n    def banner s; @order << [:text, s] end\n    alias :text :banner\n\n    ## Marks two (or more!) options as requiring each other. Only handles\n    ## undirected (i.e., mutual) dependencies. Directed dependencies are\n    ## better modeled with Trollop::die.\n    def depends *syms\n      syms.each { |sym| raise ArgumentError, _(\"unknown option '%{sym}'\") % { sym: sym } unless @specs[sym] }\n      @constraints << [:depends, syms]\n    end\n\n    ## Marks two (or more!) options as conflicting.\n    def conflicts *syms\n      syms.each { |sym| raise ArgumentError, _(\"unknown option '%{sym}'\") % { sym: sym } unless @specs[sym] }\n      @constraints << [:conflicts, syms]\n    end\n\n    ## Defines a set of words which cause parsing to terminate when\n    ## encountered, such that any options to the left of the word are\n    ## parsed as usual, and options to the right of the word are left\n    ## intact.\n    ##\n    ## A typical use case would be for subcommand support, where these\n    ## would be set to the list of subcommands. A subsequent Trollop\n    ## invocation would then be used to parse subcommand options, after\n    ## shifting the subcommand off of ARGV.","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/command_line/trollop.rb#L259-L295","documentation":"depends(*syms) records an undirected must-appear-together constraint between options. Before recording it, trollop.rb:277 verifies that each symbol is already present in @specs (registered by an earlier opt call) and raises ArgumentError for any unknown symbol. The eager check exists because constraints are resolved by symbol at parse time — a typo there would otherwise fail silently, so Trollop fails fast at declaration time.","triggerScenarios":"`depends :mode, :intensity` when :intensity was never declared, is declared only after the depends call (declaration order matters), or is passed as the string 'intensity' instead of a symbol (strings never match @specs keys).","commonSituations":"Renaming an option and forgetting to update its constraint; declaring constraints above the opt calls; passing long-name strings ('--intensity') instead of option symbols.","solutions":["Declare every referenced option with opt before calling depends — declaration order matters","Use the exact symbol from the opt declaration, not a string or the long name","Remove constraint entries that reference options you renamed or deleted"],"exampleFix":"# before\nopt :mode, 'Mode', type: :string\ndepends :mode, :intensity   # :intensity never declared -> raise\n\n# after\nopt :mode, 'Mode', type: :string\nopt :intensity, 'Intensity', type: :int\ndepends :mode, :intensity","handlingStrategy":"validation","validationCode":"# Validate constraint symbols against registered options before calling depends\ndeclared = parser.instance_variable_get(:@specs).keys\nmissing = [:mode, :intensity].reject { |s| declared.include?(s) }\nraise ArgumentError, \"depends references undeclared options: #{missing.join(', ')}\" unless missing.empty?\nparser.depends :mode, :intensity","typeGuard":null,"tryCatchPattern":"begin\n  parser.depends :mode, :intensity\nrescue ArgumentError => e\n  raise unless e.message.include?(\"unknown option\")\n  # option not declared (yet) - declare it or drop the constraint\n  parser.opt :intensity, 'Intensity', type: :int\n  parser.depends :mode, :intensity\nend","preventionTips":["Always declare options with opt before registering constraints on them - order matters","Reference options by symbol, never by string or long name","When renaming an option, grep for its symbol in depends/conflicts calls"],"tags":["puppet","trollop","cli","option-parsing","constraints"],"backgroundTag":"unknown-option-reference","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}