{"record":{"id":"ecea68fe8518a8c7","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"not-possible-to-set-key-because-it-is-restrict","errorCode":null,"errorMessage":"not possible to set '{key}' because it is restricted","messagePattern":"not possible to set '(.+?)' because it is restricted","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"modules/options.py","lineNumber":108,"sourceCode":"    def __setattr__(self, key, value):\r\n        if key in options_builtin_fields:\r\n            return super(Options, self).__setattr__(key, value)\r\n\r\n        if self.data is not None:\r\n            if key in self.data or key in self.data_labels:\r\n\r\n                # Check that settings aren't globally frozen\r\n                assert not cmd_opts.freeze_settings, \"changing settings is disabled\"\r\n\r\n                # Get the info related to the setting being changed\r\n                info = self.data_labels.get(key, None)\r\n                if info.do_not_save:\r\n                    return\r\n\r\n                # Restrict component arguments\r\n                comp_args = info.component_args if info else None\r\n                if isinstance(comp_args, dict) and comp_args.get('visible', True) is False:\r\n                    raise RuntimeError(f\"not possible to set '{key}' because it is restricted\")\r\n\r\n                # Check that this section isn't frozen\r\n                if cmd_opts.freeze_settings_in_sections is not None:\r\n                    frozen_sections = list(map(str.strip, cmd_opts.freeze_settings_in_sections.split(','))) # Trim whitespace from section names\r\n                    section_key = info.section[0]\r\n                    section_name = info.section[1]\r\n                    assert section_key not in frozen_sections, f\"not possible to set '{key}' because settings in section '{section_name}' ({section_key}) are frozen with --freeze-settings-in-sections\"\r\n\r\n                # Check that this section of the settings isn't frozen\r\n                if cmd_opts.freeze_specific_settings is not None:\r\n                    frozen_keys = list(map(str.strip, cmd_opts.freeze_specific_settings.split(','))) # Trim whitespace from setting keys\r\n                    assert key not in frozen_keys, f\"not possible to set '{key}' because this setting is frozen with --freeze-specific-settings\"\r\n\r\n                # Check shorthand option which disables editing options in \"saving-paths\"\r\n                if cmd_opts.hide_ui_dir_config and key in self.restricted_opts:\r\n                    raise RuntimeError(f\"not possible to set '{key}' because it is restricted with --hide_ui_dir_config\")\r\n\r\n                self.data[key] = value\r","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/options.py#L90-L126","documentation":"Options.__setattr__ performs several guards before allowing a settings change; this RuntimeError fires when the setting's component_args is a dict with visible=False, i.e. the setting is deliberately hidden/restricted in the UI (not meant to be set programmatically). It is a policy check, not a data problem.","triggerScenarios":"Calling shared.opts.set('key', value) or assigning opts.<key> where the OptionInfo for that key declares component_args={'visible': False}; also triggered via the settings API endpoint for such restricted keys.","commonSituations":"Extensions or scripts trying to programmatically change an internal/hidden setting; using the /sdapi/v1/options API to write a key the UI deliberately hides in this build.","solutions":["Do not set the restricted key from code; choose the user-facing setting that governs the behavior instead.","If you own the setting definition, remove 'visible': False from its component_args when registering it if programmatic writes should be allowed.","Check whether the value you need is better passed as a command-line argument at launch instead of a runtime option write."],"exampleFix":"# before\nshared.opts.set('some_hidden_key', 'value')  # RuntimeError: restricted\n\n# after\n# use the public setting or configure at launch\nshared.opts.set('sd_model_checkpoint', 'model.safetensors')  # non-restricted key","handlingStrategy":"validation","validationCode":"def can_set_option(opts, key):\n    info = opts.data_labels.get(key)\n    if info is None:\n        return True\n    comp = info.component_args if isinstance(info.component_args, dict) else None\n    return not (comp and comp.get('visible', True) is False)\n\nif can_set_option(shared.opts, key):\n    shared.opts.set(key, value)","typeGuard":"def is_settable_option(key: str) -> bool:\n    info = shared.opts.data_labels.get(key)\n    if info is None:\n        return True\n    comp = info.component_args if isinstance(info.component_args, dict) else None\n    return not (comp and comp.get('visible', True) is False)","tryCatchPattern":"try:\n    shared.opts.set(key, value)\nexcept RuntimeError as e:\n    if 'restricted' in str(e):\n        pass  # policy denies this key; not retryable\n    else:\n        raise","preventionTips":["Filter option keys against data_labels/component_args before bulk PATCHing options.","Extensions should register hidden settings with visible:False only when runtime writes are truly unwanted."],"tags":["options","settings","api","permissions"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}