{"record":{"id":"134e08771b7e8c18","repo":"puppetlabs/puppet","slug":"no-input-to-parse-given-on-command-line-or-stdin-134e08","errorCode":null,"errorMessage":"No input to parse given on command line or stdin","messagePattern":"No input to parse given on command line or stdin","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/face/parser.rb","lineNumber":154,"sourceCode":"\n    option('--format ' + _('<old, pn, or json>')) do\n      summary _(\"Get result in 'old' (deprecated format), 'pn' (new format), or 'json' (new format in JSON).\")\n    end\n\n    option('--pretty') do\n      summary _('Pretty print output. Only applicable together with --format pn or json')\n    end\n\n    when_invoked do |*args|\n      require_relative '../../puppet/pops'\n      options = args.pop\n      if options[:e]\n        dump_parse(options[:e], 'command-line-string', options, false)\n      elsif args.empty?\n        if !STDIN.tty?\n          dump_parse(STDIN.read, 'stdin', options, false)\n        else\n          raise Puppet::Error, _(\"No input to parse given on command line or stdin\")\n        end\n      else\n        files = args\n        available_files = files.select do |file|\n          Puppet::FileSystem.exist?(file)\n        end\n        missing_files = files - available_files\n\n        dumps = available_files.collect do |file|\n          dump_parse(Puppet::FileSystem.read(file, :encoding => 'utf-8'), file, options)\n        end.join(\"\")\n\n        if missing_files.empty?\n          dumps\n        else\n          dumps + _(\"One or more file(s) specified did not exist:\\n\") + missing_files.collect { |f| \"   #{f}\" }.join(\"\\n\")\n        end\n      end","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/face/parser.rb#L136-L172","documentation":"`puppet parser dump` needs Puppet code from one of three sources: the -e inline string, file arguments, or piped (non-TTY) STDIN. When none is available — no -e, no positional args, and STDIN is an interactive terminal — it raises Puppet::Error rather than silently blocking on keyboard input.","triggerScenarios":"Bare `puppet parser dump` in an interactive shell; a wrapper that forgets to pass -e or file paths; a pipeline where the producer command failed so STDIN fell back to the TTY.","commonSituations":"Exploring the new parser output interactively; CI harnesses calling parser dump with dynamically built argument lists that end up empty.","solutions":["Pass code inline: `puppet parser dump -e 'notify { \"x\": }'`","Pass manifest files: `puppet parser dump init.pp`","Pipe code in: `cat init.pp | puppet parser dump`"],"exampleFix":"# before\npuppet parser dump\n# after\npuppet parser dump -e 'notify { \"hello\": message => \"hi\" }'","handlingStrategy":"validation","validationCode":"abort 'nothing to parse: pass -e, file arguments, or pipe stdin' if ARGV.empty? && !ENV.key?('PUPPET_PARSER_EXPR') && $stdin.tty? && !options[:e]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In scripts, always pass -e or explicit file paths rather than relying on stdin","Check $stdin.tty? before invoking parser dump with no arguments"],"tags":["puppet","parser","cli","stdin","usage-error"],"backgroundTag":"missing-required-input","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}