{"record":{"id":"07c05a0eaad5b3ec","repo":"we-promise/sure","slug":"record-not-found-07c05a","errorCode":"record_not_found","errorMessage":"Rule run not found","messagePattern":"Rule run not found","errorType":"http","errorClass":"ActiveRecord::RecordNotFound","httpStatus":404,"severity":"error","filePath":"app/controllers/api/v1/rule_runs_controller.rb","lineNumber":35,"sourceCode":"    @pagy, @rule_runs = pagy(\n      rule_runs_query,\n      page: safe_page_param,\n      limit: @per_page\n    )\n\n    render :index\n  rescue InvalidFilterError => e\n    render_validation_error(e.message)\n  end\n\n  def show\n    render :show\n  end\n\n  private\n\n    def set_rule_run\n      raise ActiveRecord::RecordNotFound, \"Rule run not found\" unless valid_uuid?(params[:id])\n\n      @rule_run = rule_runs_scope.find(params[:id])\n    end\n\n    def ensure_read_scope\n      authorize_scope!(:read)\n    end\n\n    def rule_runs_scope\n      RuleRun\n        .joins(:rule)\n        .where(rules: { family_id: current_resource_owner.family.id })\n        .includes(:rule)\n    end\n\n    def apply_filters(query)\n      if params[:rule_id].present?\n        raise InvalidFilterError, \"rule_id must be a valid UUID\" unless valid_uuid?(params[:rule_id])","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/controllers/api/v1/rule_runs_controller.rb#L17-L53","documentation":"Raised by set_rule_run in Api::V1::RuleRunsController (app/controllers/api/v1/rule_runs_controller.rb:34-38). A non-UUID params[:id] trips the guard with the custom message 'Rule run not found'; otherwise rule_runs_scope — RuleRun joined to rules filtered on rules.family_id = current family — must find the row. RecordNotFound surfaces as 404 record_not_found.","triggerScenarios":"GET /api/v1/rule_runs/:id with a malformed id; a rule run whose rule belongs to another family; a run for a rule that was deleted (orphaned runs are out of scope if the rule row is gone).","commonSituations":"Copying a rule run id from another workspace/family; rules deleted during cleanup leaving stale ids in client logs or dashboards; pagination caches holding ids after a rule purge.","solutions":["List runs with GET /api/v1/rule_runs (optionally ?rule_id=) and use a returned id","Confirm the parent rule still exists and belongs to the token's family","Validate the id is a UUID before the call","Expire cached run ids when rules are deleted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"UUID_RE = /\\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\z/i\nUUID_RE.match?(id) or raise ArgumentError, 'rule run id must be a UUID'","typeGuard":null,"tryCatchPattern":"begin\n  client.get(\"/api/v1/rule_runs/#{id}\")\nrescue Faraday::ResourceNotFound\n  # 404 'Rule run not found': malformed id or run under another family's rule\nend","preventionTips":["Source run ids from GET /api/v1/rule_runs?rule_id=...","Invalidate cached run ids when the parent rule is deleted","Check the rule still exists in GET /api/v1/rules"],"tags":["rails","activerecord","record-not-found","http-404","uuid","api"],"backgroundTag":"record-not-found","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}