{"record":{"id":"4ac017fbfc5dfaa2","repo":"we-promise/sure","slug":"record-not-found-4ac017","errorCode":"record_not_found","errorMessage":"Security price not found","messagePattern":"Security price not found","errorType":"http","errorClass":"ActiveRecord::RecordNotFound","httpStatus":404,"severity":"error","filePath":"app/controllers/api/v1/security_prices_controller.rb","lineNumber":32,"sourceCode":"    @pagy, @security_prices = pagy(\n      security_prices_query,\n      page: safe_page_param,\n      limit: @per_page\n    )\n\n    render :index\n  rescue Api::V1::SecurityResourceFiltering::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_security_price\n      raise ActiveRecord::RecordNotFound, \"Security price not found\" unless valid_uuid?(params[:id])\n\n      @security_price = security_prices_scope.find(params[:id])\n    end\n\n    def ensure_read_scope\n      authorize_scope!(:read)\n    end\n\n    def security_prices_scope\n      Security::Price\n        .where(security_id: scoped_security_ids)\n        .includes(:security)\n    end\n\n    def apply_filters(query)\n      if params[:security_id].present?\n        invalid_filter!(\"security_id must be a valid UUID\") unless valid_uuid?(params[:security_id])\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/controllers/api/v1/security_prices_controller.rb#L14-L50","documentation":"Raised by set_security_price in Api::V1::SecurityPricesController (app/controllers/api/v1/security_prices_controller.rb:32). A malformed id trips the guard with 'Security price not found'; otherwise security_prices_scope — Security::Price.where(security_id: scoped_security_ids) — must contain the row. Prices for securities outside the family's scoped set 404 with record_not_found.","triggerScenarios":"GET /api/v1/security_prices/:id with a non-UUID; a price row id for a security the family does not hold; a price id taken from a provider payload rather than this API.","commonSituations":"Mixing up price-row ids with security ids; provider-synced price ids assumed globally addressable; securities leaving family scope (positions sold) making their prices 404.","solutions":["List with GET /api/v1/security_prices (optionally filtered) and use a returned id","Confirm you are using a price id, not a security id","Validate UUID format before the call","Verify the parent security is still in GET /api/v1/securities"],"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, 'security price id must be a UUID'","typeGuard":null,"tryCatchPattern":"begin\n  client.get(\"/api/v1/security_prices/#{id}\")\nrescue Faraday::ResourceNotFound\n  # 404 'Security price not found': price for an out-of-scope security\nend","preventionTips":["Never confuse price-row ids with security ids","List via GET /api/v1/security_prices before fetching by id","Verify the parent security remains in scope"],"tags":["rails","activerecord","record-not-found","http-404","uuid","securities"],"backgroundTag":"record-not-found","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}