Skip to content

Update the mock API to alphabetize paginated list queries #2776

Open

Description

@charliepark

The API will automatically sort items by name ascending if no sort_by query param is included to override that. We should update the paginated helper in the mock API to match this behavior. [Investigate this to verify, but it's likely correct.]

(From a PR)

Activity

  1. charliepark commented on Feb 5, 2026

    @charliepark
    ContributorAuthor

    Just following up with Claude's analysis of Omicron:

    Default Sorting Behavior

    For endpoints that support sorting by name or ID (most common case - like projects, instances, disks, etc.):

    • Default: name_ascending (line 427-428 in common/src/api/external/http_pagination.rs)
    • Items are sorted alphabetically by name in ascending order

    For endpoints that only support sorting by ID:

    • Default: id_ascending (line 334-335)
    • Items are sorted by UUID in ascending order

    For endpoints that sort by timestamp and ID (like audit logs):

    • Default: time_and_id_ascending (line 511-512)
    • Items are sorted by timestamp (oldest first), then by ID

    How it works

    The code uses Serde's #[serde(default = "...")] attribute on the sort_by field. When you don't provide a sort_by query parameter, it automatically applies the default:

    fn default_nameid_sort_mode() -> NameOrIdSortMode {
        NameOrIdSortMode::NameAscending  // Most common default
    }
    

    So if you call GET /v1/projects without any sort_by parameter, you'll get results sorted by project name in alphabetical order (A-Z) by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions