{"record":{"id":"eccda19bf8f29cc7","repo":"discourse/discourse","slug":"invalid-access-eccda1","errorCode":null,"errorMessage":"invalid access","messagePattern":"invalid access","errorType":"exception","errorClass":"PresenceChannel::InvalidAccess","httpStatus":403,"severity":"error","filePath":"lib/presence_channel.rb","lineNumber":133,"sourceCode":"      end\n      group_ids ||= GroupUser.where(user_id: user_id).pluck(\"group_id\")\n      return true if (group_ids & config.allowed_group_ids).present?\n    end\n    false\n  end\n\n  # Is a user allowed to enter this channel?\n  # Currently equal to the can_view? permission\n  def can_enter?(user_id: nil, group_ids: nil)\n    return false if user_id.nil?\n    can_view?(user_id: user_id, group_ids: group_ids)\n  end\n\n  # Mark a user's client as present in this channel. The client_id should be unique per\n  # browser tab. This method should be called repeatedly (at least once every DEFAULT_TIMEOUT)\n  # while the user is present in the channel.\n  def present(user_id:, client_id:)\n    raise PresenceChannel::InvalidAccess if !can_enter?(user_id: user_id)\n\n    mutex_value = SecureRandom.hex\n    result =\n      retry_on_mutex_error do\n        PresenceChannel.redis_eval(\n          :present,\n          redis_keys,\n          [name, user_id, client_id, (Time.zone.now + timeout).to_i, mutex_value],\n        )\n      end\n\n    if result == 1\n      begin\n        publish_message(entering_user_ids: [user_id])\n      ensure\n        release_mutex(mutex_value)\n      end\n    end","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/discourse/discourse/blob/1b2d7253e854205d2c95c80b2c6a1cdd42e45059/lib/presence_channel.rb#L115-L151","documentation":"Error \"invalid access\" thrown in discourse/discourse.","triggerScenarios":"Thrown at lib/presence_channel.rb:133 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"}