{"record":{"id":"ffac5f7803a0cd41","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"not-possible-to-set-key-because-it-is-restrict-ffac5f","errorCode":null,"errorMessage":"not possible to set '{key}' because it is restricted with --hide_ui_dir_config","messagePattern":"not possible to set '(.+?)' because it is restricted with --hide_ui_dir_config","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"modules/options.py","lineNumber":124,"sourceCode":"                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\n                return\r\n\r\n        return super(Options, self).__setattr__(key, value)\r\n\r\n    def __getattr__(self, item):\r\n        if item in options_builtin_fields:\r\n            return super(Options, self).__getattribute__(item)\r\n\r\n        if self.data is not None:\r\n            if item in self.data:\r\n                return self.data[item]\r\n\r\n        if item in self.data_labels:\r\n            return self.data_labels[item].default\r\n\r\n        return super(Options, self).__getattribute__(item)\r","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/options.py#L106-L142","documentation":"A second guard in Options.__setattr__: when the launcher runs with --hide-ui-dir-config and the key being set is in self.restricted_opts (path/directory-related settings like models_dir, outdir_txt2img, etc.), the write is refused with this RuntimeError. It exists so a locked-down deployment cannot have its filesystem paths redirected at runtime.","triggerScenarios":"Launching with --hide-ui-dir-config in COMMANDLINE_ARGS and then attempting to set any restricted path option (shared.opts.set on keys listed in Options.restricted_opts) via UI, API, or code.","commonSituations":"Hardened/shared installations (e.g. public demos) that lock directory config; scripts or API clients that try to change output directories while that lock is active.","solutions":["Remove --hide_ui_dir_config from COMMANDLINE_ARGS and restart if runtime path changes are legitimately needed.","Otherwise set directory configuration at launch via command-line arguments (--outdir, model path flags) instead of the options API.","API clients should filter out restricted keys before PATCHing /sdapi/v1/options."],"exampleFix":"# before (webui-user.sh)\nexport COMMANDLINE_ARGS=\"--hide-ui-dir-config\"\n# ... later: opts.set('outdir_txt2img', '/data/out')  -> RuntimeError\n\n# after\nexport COMMANDLINE_ARGS=\"--outdir-txt2img=/data/out\"","handlingStrategy":"validation","validationCode":"def safe_set(opts, key, value):\n    import modules.shared as shared\n    if shared.cmd_opts.hide_ui_dir_config and key in opts.restricted_opts:\n        return False  # locked in this deployment\n    opts.set(key, value)\n    return True","typeGuard":"def is_restricted_path_option(key: str) -> bool:\n    return key in shared.opts.restricted_opts and bool(shared.cmd_opts.hide_ui_dir_config)","tryCatchPattern":"try:\n    shared.opts.set(key, value)\nexcept RuntimeError as e:\n    if 'hide_ui_dir_config' in str(e):\n        # path settings locked; configure at launch instead\n        pass\n    else:\n        raise","preventionTips":["In hardened deployments set all paths via command-line args, not runtime options.","API clients should GET /sdapi/v1/options and skip keys the server marks restricted."],"tags":["options","settings","paths","deployment","permissions"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}