we-promise/sure · error · ActiveRecord::RecordNotFound

record_not_found

record_not_found

Error message

The requested resource was not found

What it means

Raised by set_sync in Api::V1::SyncsController (app/controllers/api/v1/syncs_controller.rb:34). Non-UUID ids fail the guard; otherwise family_syncs_query — Sync.for_family(current family, resource_owner: owner) preloading syncable and children — must find the row. Syncs belonging to other families or to provider connections outside the owner's visibility 404 as record_not_found.

Source

Thrown at app/controllers/api/v1/syncs_controller.rb:34

    render :index
  end

  def latest
    @sync = family_syncs_query.preload(:syncable, :children).ordered.first
    return render json: { data: nil } unless @sync

    render :show
  end

  def show
    render :show
  end

  private

    def set_sync
      raise ActiveRecord::RecordNotFound unless valid_uuid?(params[:id])

      @sync = family_syncs_query.preload(:syncable, :children).find(params[:id])
    end

    def ensure_read_scope
      authorize_scope!(:read)
    end

    def family_syncs_query
      Sync.for_family(current_resource_owner.family, resource_owner: current_resource_owner)
    end
end

View on GitHub (pinned to e69894adb9)

Solutions

  1. List with GET /api/v1/syncs (or latest) and use a current id
  2. Confirm the X-Api-Key owner matches the sync's provider connection
  3. Validate UUID format before the call
  4. After re-authenticating a provider, re-discover sync ids instead of reusing old ones
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, 'sync id must be a UUID'

Try / catch

begin
  client.get("/api/v1/syncs/#{id}")
rescue Faraday::ResourceNotFound
  # 404: sync not visible to this family/resource owner
end

Prevention

When it happens

Trigger: GET /api/v1/syncs/:id with a malformed id; a sync id from another family; a sync created by a different family member's connection that for_family excludes for this resource owner.

Common situations: Monitoring dashboards caching sync ids across key rotations; ids logged from a shared error tracker spanning multiple deployments; polling an old sync after re-authenticating a provider (which may start a new sync).

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/5c154ce6529e40af. Report an issue: GitHub.