{"record":{"id":"baa8aa1062b0078d","repo":"discourse/discourse","slug":"raise-discourse-invalidaccess-new","errorCode":null,"errorMessage":"raise Discourse::InvalidAccess.new","messagePattern":"raise Discourse::InvalidAccess\\.new","errorType":"exception","errorClass":"Discourse::InvalidAccess","httpStatus":403,"severity":"error","filePath":"app/controllers/admin/themes_controller.rb","lineNumber":202,"sourceCode":"      on_failed_policy(:ensure_remote_themes_are_not_allowlisted) { raise Discourse::InvalidAccess }\n      on_model_errors { |theme:| render json: theme.errors, status: :unprocessable_entity }\n      on_model_not_found(:theme) do |result|\n        raise Discourse::NotFound if !result.exception\n        render json: failed_json.merge(errors: result.exception.message), status: :bad_request\n      end\n    end\n  end\n\n  def update\n    @theme = Theme.include_relations.find_by(id: params[:id])\n    raise Discourse::InvalidParameters.new(:id) unless @theme\n\n    original_json = ThemeSerializer.new(@theme, root: false).to_json\n    disables_component = [false, \"false\"].include?(theme_params[:enabled])\n    enables_component = [true, \"true\"].include?(theme_params[:enabled])\n\n    if @theme.system? && (theme_params.keys - Theme::EDITABLE_SYSTEM_ATTRIBUTES).present?\n      raise Discourse::InvalidAccess.new\n    end\n\n    %i[\n      name\n      color_scheme_id\n      dark_color_scheme_id\n      user_selectable\n      enabled\n      auto_update\n    ].each do |field|\n      @theme.public_send(\"#{field}=\", theme_params[field]) if theme_params.key?(field)\n    end\n\n    @theme.child_theme_ids = theme_params[:child_theme_ids] if theme_params.key?(:child_theme_ids)\n\n    @theme.parent_theme_ids = theme_params[:parent_theme_ids] if theme_params.key?(\n      :parent_theme_ids,\n    )","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/discourse/discourse/blob/1b2d7253e854205d2c95c80b2c6a1cdd42e45059/app/controllers/admin/themes_controller.rb#L184-L220","documentation":"Error \"raise Discourse::InvalidAccess.new\" thrown in discourse/discourse.","triggerScenarios":"Thrown at app/controllers/admin/themes_controller.rb:202 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":"1b2d7253e854205d2c95c80b2c6a1cdd42e45059","analyzedAt":"2026-08-26T03:11:08.302Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}