{"record":{"id":"07c12f7911da3709","repo":"Unity-Technologies/ml-agents","slug":"sampler-configuration-does-not-contain-sampler-par","errorCode":null,"errorMessage":"Sampler configuration does not contain sampler_parameters : {d}.","messagePattern":"Sampler configuration does not contain sampler_parameters : (.+?)\\.","errorType":"validation","errorClass":"TrainerConfigError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/settings.py","lineNumber":301,"sourceCode":"        d: Union[Mapping, float], t: type\n    ) -> \"ParameterRandomizationSettings\":\n        \"\"\"\n        Helper method to a ParameterRandomizationSettings class. Meant to be registered with\n        cattr.register_structure_hook() and called with cattr.structure(). This is needed to handle\n        the special Enum selection of ParameterRandomizationSettings classes.\n        \"\"\"\n        if isinstance(d, (float, int)):\n            return ConstantSettings(value=d)\n        if not isinstance(d, Mapping):\n            raise TrainerConfigError(\n                f\"Unsupported parameter randomization configuration {d}.\"\n            )\n        if \"sampler_type\" not in d:\n            raise TrainerConfigError(\n                f\"Sampler configuration does not contain sampler_type : {d}.\"\n            )\n        if \"sampler_parameters\" not in d:\n            raise TrainerConfigError(\n                f\"Sampler configuration does not contain sampler_parameters : {d}.\"\n            )\n        enum_key = ParameterRandomizationType(d[\"sampler_type\"])\n        t = enum_key.to_settings()\n        return strict_to_cls(d[\"sampler_parameters\"], t)\n\n    @staticmethod\n    def unstructure(d: \"ParameterRandomizationSettings\") -> Mapping:\n        \"\"\"\n        Helper method to a ParameterRandomizationSettings class. Meant to be registered with\n        cattr.register_unstructure_hook() and called with cattr.unstructure().\n        \"\"\"\n        _reversed_mapping = {\n            UniformSettings: ParameterRandomizationType.UNIFORM,\n            GaussianSettings: ParameterRandomizationType.GAUSSIAN,\n            MultiRangeUniformSettings: ParameterRandomizationType.MULTIRANGEUNIFORM,\n            ConstantSettings: ParameterRandomizationType.CONSTANT,\n        }","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/settings.py#L283-L319","documentation":"The parameter randomization structure hook requires both `sampler_type` and `sampler_parameters` keys; after validating sampler_type it checks for `sampler_parameters` and raises this error if absent. The sampler_parameters value is then strictly converted into the concrete sampler settings class.","triggerScenarios":"Writing `environment_parameters: {my_param: {sampler_type: uniform}}` without the sibling `sampler_parameters` mapping.","commonSituations":"Copying only the sampler_type line from docs, or deleting sampler_parameters when editing values, leaving an incomplete sampler block.","solutions":["Add a `sampler_parameters` mapping with the required fields (e.g. min_value, max_value for uniform).","Verify indentation so sampler_parameters nests under the parameter name.","Compare against a working example config from the ML-Agents repo."],"exampleFix":"# before\nmy_param:\n  sampler_type: uniform\n\n# after\nmy_param:\n  sampler_type: uniform\n  sampler_parameters:\n    min_value: 1.0\n    max_value: 5.0","handlingStrategy":"validation","validationCode":"for name, spec in cfg.get('environment_parameters', {}).items():\n    if isinstance(spec, dict) and 'sampler_parameters' not in spec:\n        raise ValueError(f\"environment_parameters[{name}] missing 'sampler_parameters'\")","typeGuard":"def has_sampler_parameters(spec) -> bool:\n    return isinstance(spec, dict) and isinstance(spec.get('sampler_parameters'), dict)","tryCatchPattern":"try:\n    settings = TrainerSettings.structure(raw)\nexcept TrainerConfigError as e:\n    if 'sampler_parameters' in str(e):\n        print('Add sampler_parameters with min_value/max_value etc.')\n    raise","preventionTips":["Always pair sampler_type with sampler_parameters in the same mapping","Validate nested keys with a schema before training runs","Keep a canonical example config per sampler type"],"tags":["config","yaml","parameter-randomization","missing-key"],"backgroundTag":"missing-required-argument","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}