{"record":{"id":"eebee99d9166c5e4","repo":"theforeman/foreman","slug":"hostgroup-not-found-or-not-accessible","errorCode":null,"errorMessage":"Hostgroup not found or not accessible","messagePattern":"Hostgroup not found or not accessible","errorType":"exception","errorClass":"HostgroupNotFoundError","httpStatus":null,"severity":"error","filePath":"app/services/foreman/renderer/scope/macros/helpers.rb","lineNumber":29,"sourceCode":"            sections only: %w[all]\n          end\n\n          apipie :method, \"Returns counter increased by given value (as String) stored in a hostgroup param named 'sequence_num_xxx'\" do\n            required :hostgroup_name, String, \"hostgroup title to store in (e.g. RHEL7/base)\"\n            optional :increment, Integer, \"integer increment, can be negative too\", default: 1\n            optional :name, String, \"name of the sequence (prefix for hostgroup parameter)\", default: 'default'\n            optional :prefix, Integer, \"leading zeroes\", default: 1\n            returns String, \"String with incremented value or empty string if hostgroup not found or access was denied\"\n            example 'sequence_hostgroup_param_next(\"myHG\", 10) #=> 10'\n            example 'sequence_hostgroup_param_next(\"myHG\", 2, \"kiosk\", 5) #=> 00002'\n          end\n          def sequence_hostgroup_param_next(hostgroup_name, increment = 1, name = \"default\", prefix = 1)\n            # This helper cannot be in a host-context because it was built mainly for discovery naming\n            # where host-hostgroup was not yet set. This macro allows accessing hostgroup parameters\n            # named starting with \"sequence_num_\" and increasing those counters which is not a security\n            # threat.\n            hostgroup = Hostgroup.find_by_title(hostgroup_name)\n            raise HostgroupNotFoundError.new unless hostgroup\n            result = 0\n            ::Foreman::AdvisoryLockManager.with_transaction_lock(\"sequence_hostgroup_param_next\") do\n              param = GroupParameter.find_or_create_by!(name: \"sequence_num_#{name}\", key_type: \"integer\", reference_id: hostgroup.id)\n              param.value ||= 0\n              param.value += increment\n              param.save! unless preview?\n              result = param.value\n            end\n            \"%0#{prefix}d\" % result\n          end\n\n          apipie :method, \"Parse the YAML document into a Ruby Hash object\" do\n            required :data, String\n            returns Hash\n            example 'parse_yaml(\"---\\nkey: value\\n\") #=> {\"key\"=>\"value\"}'\n          end\n          def parse_yaml(data)\n            YAML.safe_load(data)","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/services/foreman/renderer/scope/macros/helpers.rb#L11-L47","documentation":"Error \"Hostgroup not found or not accessible\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/services/foreman/renderer/scope/macros/helpers.rb:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}