we-promise/sure · error · ActiveRecord::RecordNotFound
record_not_found
record_not_found
Error message
Security price not found
What it means
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.
Source
Thrown at app/controllers/api/v1/security_prices_controller.rb:32
@pagy, @security_prices = pagy(
security_prices_query,
page: safe_page_param,
limit: @per_page
)
render :index
rescue Api::V1::SecurityResourceFiltering::InvalidFilterError => e
render_validation_error(e.message)
end
def show
render :show
end
private
def set_security_price
raise ActiveRecord::RecordNotFound, "Security price not found" unless valid_uuid?(params[:id])
@security_price = security_prices_scope.find(params[:id])
end
def ensure_read_scope
authorize_scope!(:read)
end
def security_prices_scope
Security::Price
.where(security_id: scoped_security_ids)
.includes(:security)
end
def apply_filters(query)
if params[:security_id].present?
invalid_filter!("security_id must be a valid UUID") unless valid_uuid?(params[:security_id])
View on GitHub (pinned to e69894adb9)
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
Defensive patterns
Strategy: try-catch
Validate before calling
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
UUID_RE.match?(id) or raise ArgumentError, 'security price id must be a UUID' Try / catch
begin
client.get("/api/v1/security_prices/#{id}")
rescue Faraday::ResourceNotFound
# 404 'Security price not found': price for an out-of-scope security
end Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/4ac017fbfc5dfaa2.
Report an issue: GitHub.