{"record":{"id":"b63df50d9dcbf52d","repo":"puppetlabs/puppet","slug":"module-module-name-not-found-in-environment-e-b63df5","errorCode":null,"errorMessage":"Module %{module_name} not found in environment %{environment_name}.","messagePattern":"Module %(.+?) not found in environment %(.+?)\\.","errorType":"exception","errorClass":"Puppet::Module::MissingModule","httpStatus":null,"severity":"error","filePath":"lib/puppet/info_service/task_information_service.rb","lineNumber":29,"sourceCode":"      mod.tasks.map do |task|\n        # If any task is malformed continue to list other tasks in module\n\n        task.validate\n        { :module => { :name => task.module.name }, :name => task.name, :metadata => task.metadata }\n      rescue Puppet::Module::Task::Error => err\n        Puppet.log_exception(err)\n        nil\n      end\n    end.flatten.compact\n  end\n\n  def self.task_data(environment_name, module_name, task_name)\n    # raise EnvironmentNotFound if applicable\n    Puppet.lookup(:environments).get!(environment_name)\n\n    pup_module = Puppet::Module.find(module_name, environment_name)\n    if pup_module.nil?\n      raise Puppet::Module::MissingModule, _(\"Module %{module_name} not found in environment %{environment_name}.\") %\n                                           { module_name: module_name, environment_name: environment_name }\n    end\n\n    task = pup_module.tasks.find { |t| t.name == task_name }\n    if task.nil?\n      raise Puppet::Module::Task::TaskNotFound.new(task_name, module_name)\n    end\n\n    begin\n      task.validate\n      { :metadata => task.metadata, :files => task.files }\n    rescue Puppet::Module::Task::Error => err\n      { :metadata => nil, :files => [], :error => err.to_h }\n    end\n  end\nend\n","sourceCodeStart":11,"sourceCodeEnd":46,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/info_service/task_information_service.rb#L11-L46","documentation":"TaskInformationService.task_data is the task counterpart of plan_data: after resolving the environment, Puppet::Module.find(module_name, environment_name) returning nil raises Puppet::Module::MissingModule. The environment exists but contains no module by that name in its modulepath. It backs 'puppet task show' / 'puppet task run' metadata lookups and Puppet Server task APIs.","triggerScenarios":"Calling Puppet::InfoService::TaskInformationService.task_data('production', 'package', 'install') when the package module is not deployed to production; wrong environment argument; module name case mismatch with the directory; task invoked from a node whose environment lacks the module.","commonSituations":"Running Bolt/puppet task against an environment where code deployment (r10k/Code Manager) had not yet synced the module; renames of task modules; typos in the module segment of task names (module::task).","solutions":["Check the module exists in that environment: ls $(puppet config print environmentpath)/<env>/modules/<module>","Redeploy the environment code (r10k deploy environment <env> or Code Manager) if the module should be there","Use the fully-qualified task name matching module directory casing: <module>/<task>","Verify with `puppet task show --environment <env>` that the task is discoverable before programmatic calls"],"exampleFix":"# before\nPuppet::InfoService::TaskInformationService.task_data('production', 'package', 'init')\n# => Puppet::Module::MissingModule: Module package not found in environment production.\n\n# after: deploy module then retry\nr10k deploy environment production -p\nPuppet::InfoService::TaskInformationService.task_data('production', 'package', 'init')","handlingStrategy":"validation","validationCode":"Puppet.lookup(:environments).get!(environment_name)\nraise Puppet::Module::MissingModule if Puppet::Module.find(module_name, environment_name).nil?\ndata = Puppet::InfoService::TaskInformationService.task_data(environment_name, module_name, task_name)","typeGuard":null,"tryCatchPattern":"begin\n  data = Puppet::InfoService::TaskInformationService.task_data(env, mod, task)\nrescue Puppet::Module::MissingModule\n  data = nil  # caller reports 'task not deployed' without a stack trace\nend","preventionTips":["Gate task runs on `puppet task show <module>/<task> --environment <env>` succeeding","Tie environment deploys to task execution in pipelines so code and metadata never diverge","Check module directory casing against the task name's module segment"],"tags":["puppet","tasks","module-resolution","environment","bolt"],"backgroundTag":"module-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}