AUTOMATIC1111/stable-diffusion-webui · warning · RuntimeError

not possible to set '{key}' because it is restricted with --

Error message

not possible to set '{key}' because it is restricted with --hide_ui_dir_config

What it means

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.

Source

Thrown at modules/options.py:124

                comp_args = info.component_args if info else None
                if isinstance(comp_args, dict) and comp_args.get('visible', True) is False:
                    raise RuntimeError(f"not possible to set '{key}' because it is restricted")

                # Check that this section isn't frozen
                if cmd_opts.freeze_settings_in_sections is not None:
                    frozen_sections = list(map(str.strip, cmd_opts.freeze_settings_in_sections.split(','))) # Trim whitespace from section names
                    section_key = info.section[0]
                    section_name = info.section[1]
                    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"

                # Check that this section of the settings isn't frozen
                if cmd_opts.freeze_specific_settings is not None:
                    frozen_keys = list(map(str.strip, cmd_opts.freeze_specific_settings.split(','))) # Trim whitespace from setting keys
                    assert key not in frozen_keys, f"not possible to set '{key}' because this setting is frozen with --freeze-specific-settings"

                # Check shorthand option which disables editing options in "saving-paths"
                if cmd_opts.hide_ui_dir_config and key in self.restricted_opts:
                    raise RuntimeError(f"not possible to set '{key}' because it is restricted with --hide_ui_dir_config")

                self.data[key] = value
                return

        return super(Options, self).__setattr__(key, value)

    def __getattr__(self, item):
        if item in options_builtin_fields:
            return super(Options, self).__getattribute__(item)

        if self.data is not None:
            if item in self.data:
                return self.data[item]

        if item in self.data_labels:
            return self.data_labels[item].default

        return super(Options, self).__getattribute__(item)

View on GitHub (pinned to 82a973c043)

Solutions

  1. Remove --hide_ui_dir_config from COMMANDLINE_ARGS and restart if runtime path changes are legitimately needed.
  2. Otherwise set directory configuration at launch via command-line arguments (--outdir, model path flags) instead of the options API.
  3. API clients should filter out restricted keys before PATCHing /sdapi/v1/options.

Example fix

# before (webui-user.sh)
export COMMANDLINE_ARGS="--hide-ui-dir-config"
# ... later: opts.set('outdir_txt2img', '/data/out')  -> RuntimeError

# after
export COMMANDLINE_ARGS="--outdir-txt2img=/data/out"
Defensive patterns

Strategy: validation

Validate before calling

def safe_set(opts, key, value):
    import modules.shared as shared
    if shared.cmd_opts.hide_ui_dir_config and key in opts.restricted_opts:
        return False  # locked in this deployment
    opts.set(key, value)
    return True

Type guard

def is_restricted_path_option(key: str) -> bool:
    return key in shared.opts.restricted_opts and bool(shared.cmd_opts.hide_ui_dir_config)

Try / catch

try:
    shared.opts.set(key, value)
except RuntimeError as e:
    if 'hide_ui_dir_config' in str(e):
        # path settings locked; configure at launch instead
        pass
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of AUTOMATIC1111/stable-diffusion-webui@82a973c043 (2026-08-14). Data as JSON: /api/errors/ffac5f7803a0cd41. Report an issue: GitHub.