Skip to content

feat(policy): add sort support to listobligations api#3300

Merged
dsm20 merged 19 commits intomainfrom
add-sort-support-listobligations-api
Apr 15, 2026
Merged

feat(policy): add sort support to listobligations api#3300
dsm20 merged 19 commits intomainfrom
add-sort-support-listobligations-api

Conversation

@dsm20
Copy link
Copy Markdown
Contributor

@dsm20 dsm20 commented Apr 13, 2026

Proposed Changes

Resolves DSPX-2690

Changes

Protoservice/policy/obligations/obligations.proto

  • SortObligationsType enum (UNSPECIFIED, NAME, FQN, CREATED_AT, UPDATED_AT)
  • ObligationsSort message (field + direction)
  • repeated ObligationsSort sort = 11 on ListObligationsRequest with max_items = 1 constraint
  • Regenerated protos and docs

SQLservice/policy/db/queries/obligations.sql

  • CASE WHEN sort blocks in listObligations query for 4 fields (8 blocks total)
  • FQN sort uses constructed expression fqns.fqn || '/obl/' || LOWER(od.name) since obligation FQNs aren't stored in attribute_fqns
  • Fallback od.created_at DESC

Goservice/policy/db/utils.go + service/policy/db/obligations.go

  • GetObligationsSortParams(): maps enum to SQL-compatible field/direction strings
  • ListObligations handler wired to call mapper and pass params to sqlc query
  • Added sortFieldName and sortFieldFQN constants in utils.go (same pattern as sortFieldCreatedAt/sortFieldUpdatedAt from feat(policy): add sort ListSubjectMappings API #3255)

Tests

  • 12 unit tests for the enum mapper helper (nil, empty, unspecified, each field + direction)
  • 9 integration tests (name ASC/DESC, fqn ASC/DESC, created_at ASC/DESC, updated_at ASC/DESC, unspecified fallback) using createSortTestObligations and createNamedSortTestObligations suite helpers
  • Protovalidate sort constraint test (Test_ListObligationsRequest_Sort)

Notes

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

Summary by CodeRabbit

  • New Features

    • Added sorting to the obligations list API (name, FQN, created_at, updated_at) with ASC/DESC, single-sort-item constraint, and default ordering created_at DESC (ties by id ASC).
  • Tests

    • Added unit and integration tests covering all sort fields, directions, multi-namespace FQN ordering, unspecified fallback, and request validation for max-items.
  • Documentation

    • Updated API docs and table of contents to document sorting and removed an obsolete request description.

dsm20 added 11 commits April 10, 2026 14:00
has buf.validate as per usual and comments for docs. regen protos as
well
api-level tests for no items, 1 item, and 2 items sort (pass pass fail)
fqn and name in utils
in listObligations query, remove ORDER BY replace with CASE WHEN block.
FQN is assembled here. also regenerated sqlc
this is getting saved for a later PR since its inconsistent across
listAPIs
12 unit tests, full coverage) in utils_test.go
wire sort params into the go DB function in /db/obligations.go
full coverage (created_at, updated_at, name, fqn. two helpers for time
based and name based sorting. uses assertIDsInOrder helper across each
integration test
@dsm20 dsm20 requested review from a team as code owners April 13, 2026 19:17
@dsm20 dsm20 marked this pull request as draft April 13, 2026 19:18
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces sorting capabilities to the ListObligations API, enabling clients to request ordered data based on specific fields. The changes involve updating the protocol definitions, database query logic, and service layer to handle sort parameters, while maintaining backward compatibility with existing default ordering.

Highlights

  • API Enhancement: Added strongly-typed sort support to the ListObligations RPC, allowing results to be ordered by name, FQN, created_at, or updated_at.
  • Database Updates: Updated the SQL query for listing obligations to support dynamic sorting using CASE statements, ensuring efficient ordering.
  • Testing: Implemented comprehensive unit and integration tests to verify sorting functionality, including edge cases and validation constraints.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: docs/openapi/**/* (1)
    • docs/openapi/policy/obligations/obligations.openapi.yaml
  • Ignored by pattern: protocol/**/* (1)
    • protocol/go/policy/obligations/obligations.pb.go
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The obligations list is long, To sort them right, not wrong. With fields defined and SQL set, The best results you'll surely get.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation labels Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

Warning

Rate limit exceeded

@dsm20 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 2 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 2 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 47578751-1d17-456a-8043-e3fdc19b8a88

📥 Commits

Reviewing files that changed from the base of the PR and between f9cbf88 and 0812edc.

📒 Files selected for processing (1)
  • service/policy/db/obligations.sql.go
📝 Walkthrough

Walkthrough

Adds single-field typed sorting to ListObligations end-to-end: new proto enum/message and OpenAPI schemas, validator constraint (max 1), GetObligationsSortParams helper, dynamic CASE-driven SQL ORDER BY with direction, wiring through DB call params, unit/integration tests, and docs updates. Default ordering remains created_at DESC, id ASC.

Changes

Cohort / File(s) Summary
Proto Definitions
service/policy/obligations/obligations.proto
Added SortObligationsType enum and ObligationsSort message; added repeated ObligationsSort sort = 11 to ListObligationsRequest with max_items = 1 and documented default ordering.
OpenAPI / Docs
docs/openapi/policy/.../obligations.openapi.yaml, docs/grpc/index.html
Added policy.SortDirection, policy.obligations.SortObligationsType, and policy.obligations.ObligationsSort schemas; updated ListObligationsRequest to accept optional sort (maxItems:1); removed Definitions description from GetObligationRequest; updated TOC/docs.
DB SQL Query
service/policy/db/queries/obligations.sql
Replaced fixed ORDER BY od.created_at DESC with conditional parameter-driven ORDER BY (CASE branches) supporting name, fqn, created_at, updated_at with ASC/DESC and fallback to created_at DESC.
DB Go Wiring
service/policy/db/obligations.sql.go, service/policy/db/obligations.go
Extended listObligationsParams with SortField/SortDirection, adjusted parameter indices; ListObligations now calls GetObligationsSortParams and forwards sort params to query.
DB Utilities & Tests
service/policy/db/utils.go, service/policy/db/utils_test.go
Added GetObligationsSortParams(sort []*obligations.ObligationsSort) (string,string) mapping proto enum+direction → SQL field and direction; unit tests cover nil/empty/UNSPECIFIED and supported fields/directions, defaulting direction to ASC when omitted.
Validation Tests
service/policy/obligations/obligations_test.go
Added Test_ListObligationsRequest_Sort to validate sort max-items constraint (single allowed, multiples rejected).
Integration Tests
service/integration/obligations_test.go
Added integration tests exercising sorting by NAME, FQN, CREATED_AT, UPDATED_AT (ASC/DESC), UNSPECIFIED fallback, deterministic fixtures, and helpers to create/cleanup test obligations.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Server
  participant Validator
  participant Utils
  participant DB
  Client->>Server: ListObligationsRequest (optional sort)
  Server->>Validator: validate request
  Validator-->>Server: validation result
  Server->>Utils: GetObligationsSortParams(sort)
  Utils-->>Server: (sort_field, sort_direction)
  Server->>DB: listObligations(params including sort_field, sort_direction)
  DB-->>Server: rows ordered per CASE/ORDER BY
  Server-->>Client: ListObligationsResponse (ordered results)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • c-r33d
  • alkalescent

Poem

"I’m a rabbit sorting rows tonight,
hopping names and times just right,
FQN, created_at, ASC or DESC,
one tiny field, one tidy quest—
hoppity order, obligations rest. 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding sort support to the ListObligations API, which is clearly the primary objective reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-sort-support-listobligations-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dsm20 dsm20 changed the title Add sort support listobligations api policy(feat): add sort support to listobligations api Apr 13, 2026
@dsm20 dsm20 changed the title policy(feat): add sort support to listobligations api feat(policy): add sort support to listobligations api Apr 13, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces sorting capabilities for the ListObligations endpoint, allowing results to be ordered by name, FQN, creation date, or update date. The implementation includes updates to the protobuf definitions, service logic to parse sort parameters, and SQL queries utilizing CASE statements for dynamic ordering. Comprehensive integration and unit tests have been added to verify the new functionality. Feedback highlights that the SQL implementation lacks the 'id ASC' tie-breaker mentioned in the documentation, which is necessary to ensure deterministic pagination when multiple records share the same timestamp.

Comment thread service/policy/db/queries/obligations.sql
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 208.177273ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 103.500924ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 411.818251ms
Throughput 242.83 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.019836434s
Average Latency 438.558577ms
Throughput 113.59 requests/second

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/grpc/index.html`:
- Line 13206: Restore a non-empty description for the GetObligationRequest entry
in the generated docs by replacing the empty paragraph at the
GetObligationRequest section with a short summary (e.g., "Request message to
retrieve obligation details by ID and optional filters") so the documentation
regains context; locate the GetObligationRequest heading in the generated HTML
and update the empty <p>...</p> into a concise one-line description matching the
request purpose.
- Around line 13573-13580: The docs claim a tie-breaker "id ASC (tie-breaker)"
for ListObligationsRequest.sort/ObligationsSort which is not implemented; update
the HTML table cell describing the sort field in docs/grpc/index.html to remove
or neutralize the specific tie-breaker language and instead state the concrete
default ordering that matches the service (e.g., "created_at DESC" and leave
tie-breaking as implementation-defined or deferred), ensuring the text for the
sort field (the <td> describing ObligationsSort) matches actual endpoint
behavior.

In `@docs/openapi/policy/obligations/obligations.openapi.yaml`:
- Around line 1787-1790: The docs for ListObligationsRequest.sort currently
assert a tie-breaker "then id ASC (tie-breaker)" which is not implemented;
update the description for the ListObligationsRequest.sort field by removing the
tie-breaker clause and any wording that implies a stable secondary ordering,
leaving only the documented default ordering that matches current endpoint
behavior (e.g., "created_at DESC" or the existing default phrasing) so the
OpenAPI text no longer guarantees id ASC as a tie-breaker.
- Around line 547-553: Update the policy.SortDirection schema to document how
SORT_DIRECTION_UNSPECIFIED should be treated: add an endpoint-neutral
description stating that SORT_DIRECTION_UNSPECIFIED maps to ascending order
(UNSPECIFIED => ASC) and note that concrete per-endpoint default ordering should
still be documented in each request's docs; reference the enum value
SORT_DIRECTION_UNSPECIFIED and the schema name policy.SortDirection so the
change is applied to the central enum definition rather than individual
endpoints.

In `@service/integration/obligations_test.go`:
- Around line 1990-2000: The helper createNamedSortTestObligations currently
always uses nsExampleCom so it creates all obligations in one namespace and
masks FQN-based sorting bugs; modify createNamedSortTestObligations to create
obligations across multiple namespaces (e.g., alternate between nsExampleCom and
another test namespace obtained via s.getNamespaceData or accept a namespace
list) by fetching distinct namespaceIDs with s.getNamespaceData (or use existing
namespace fixtures) and using those namespaceIDs when calling
s.createObligation; update the related fixtures/tests (including the similar
code around lines 2036-2064) so the generated obligations span at least two
namespaces to properly exercise full FQN sorting.

In `@service/policy/db/queries/obligations.sql`:
- Around line 190-199: The ORDER BY lacks a final unique tie-breaker, causing
nondeterministic pagination; update the ORDER BY in obligations.sql (the CASE
expressions and final default) to always append od.id ASC as the ultimate
deterministic tie-breaker (so the current tail "od.created_at DESC" becomes
"od.created_at DESC, od.id ASC" and ensure id ASC is applied after any
CASE-driven sort to satisfy the contract "created_at DESC, then id ASC").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a2eecd90-c407-411a-a178-4b5469d1885b

📥 Commits

Reviewing files that changed from the base of the PR and between 888a4f0 and cb39c35.

⛔ Files ignored due to path filters (1)
  • protocol/go/policy/obligations/obligations.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (10)
  • docs/grpc/index.html
  • docs/openapi/policy/obligations/obligations.openapi.yaml
  • service/integration/obligations_test.go
  • service/policy/db/obligations.go
  • service/policy/db/obligations.sql.go
  • service/policy/db/queries/obligations.sql
  • service/policy/db/utils.go
  • service/policy/db/utils_test.go
  • service/policy/obligations/obligations.proto
  • service/policy/obligations/obligations_test.go

Comment thread docs/grpc/index.html
Comment thread docs/grpc/index.html
Comment thread docs/openapi/policy/obligations/obligations.openapi.yaml
Comment thread docs/openapi/policy/obligations/obligations.openapi.yaml
Comment thread service/integration/obligations_test.go Outdated
Comment thread service/policy/db/queries/obligations.sql
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 174.623313ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 88.384053ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 410.435714ms
Throughput 243.64 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.74339683s
Average Latency 405.948438ms
Throughput 122.72 requests/second

@dsm20 dsm20 force-pushed the add-sort-support-listobligations-api branch from 6e0ee93 to 29f6256 Compare April 15, 2026 14:36
@policy-bot-opentdf policy-bot-opentdf Bot dismissed stale reviews from c-r33d April 15, 2026 14:36

Invalidated by push of 29f6256

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@service/policy/db/utils_test.go`:
- Around line 655-669: Add a new test case to the existing sort mapping table
that asserts FQN with an explicit DESC direction; specifically create a case
alongside the existing "FQN with ASC" and unspecified-direction cases using an
obligations.ObligationsSort with Field:
obligations.SortObligationsType_SORT_OBLIGATIONS_TYPE_FQN and Direction:
policy.SortDirection_SORT_DIRECTION_DESC, and set expectedField to "fqn" and
expectedDir to "DESC" so the test verifies the mapper returns the correct
descending mapping.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d6502799-58a3-4a00-9c55-9ce2b45a47cf

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0ee93 and 29f6256.

📒 Files selected for processing (1)
  • service/policy/db/utils_test.go

Comment thread service/policy/db/utils_test.go
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 188.19596ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 95.673508ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 402.250903ms
Throughput 248.60 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.706226774s
Average Latency 415.892423ms
Throughput 119.89 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 200.862188ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 103.993068ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 397.613326ms
Throughput 251.50 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.106203736s
Average Latency 399.592235ms
Throughput 124.67 requests/second

now FQN is simply namespace + obligation name, instead of adding in the arbitrary "/obl/". this is for futureproofing in the event we decide to rename the FQN to some other structure where /obl/ becomes antiquated
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 201.138268ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 95.561967ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 404.675569ms
Throughput 247.11 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 42.695716059s
Average Latency 425.493713ms
Throughput 117.11 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 175.038651ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 92.86798ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 423.237087ms
Throughput 236.27 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.267139124s
Average Latency 410.704646ms
Throughput 121.16 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

@dsm20 dsm20 added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 9221cac Apr 15, 2026
38 checks passed
@dsm20 dsm20 deleted the add-sort-support-listobligations-api branch April 15, 2026 19:13
github-merge-queue Bot pushed a commit that referenced this pull request Apr 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.24.0](protocol/go/v0.23.0...protocol/go/v0.24.0)
(2026-04-17)


### Features

* **policy:** add GetObligationTrigger RPC
([#3318](#3318))
([d68e39d](d68e39d))
* **policy:** add sort ListSubjectMappings API
([#3255](#3255))
([9d5d757](9d5d757))
* **policy:** add sort support to ListKeyAccessServer
([#3287](#3287))
([7fae2d7](7fae2d7))
* **policy:** add sort support to listobligations api
([#3300](#3300))
([9221cac](9221cac))
* **policy:** add sort support to ListSubjectConditionSets API
([#3272](#3272))
([9010f12](9010f12))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 20, 2026
### Proposed Changes

Resolves DSPX-2691

- Adds strongly-typed sort support to ListRegisteredResources RPC,
following the pattern established in #3223 (ListAttributes), #3255
(ListSubjectMappings), #3272 (ListSubjectConditionSets), #3300
(ListObligations), and the ListKeyAccessServers PR
- Sortable fields: name, created_at, updated_at (ASC/DESC), with
backward-compatible fallback to created_at DESC

### Changes

**Proto** —
`service/policy/registeredresources/registered_resources.proto`
- `SortRegisteredResourcesType` enum (UNSPECIFIED, NAME, CREATED_AT,
UPDATED_AT)
- `RegisteredResourcesSort` message (field + direction)
- `repeated RegisteredResourcesSort sort = 11` on
`ListRegisteredResourcesRequest` with `max_items = 1` constraint
- Regenerated protos and docs

**SQL** — `service/policy/db/queries/registered_resources.sql`
- CASE WHEN sort blocks in `listRegisteredResources` query for 3 fields
(6 blocks total)
- Fallback `r.created_at DESC`

**Go** — `service/policy/db/utils.go` +
`service/policy/db/registered_resources.go`
- `GetRegisteredResourcesSortParams()`: maps enum to SQL-compatible
field/direction strings
- `ListRegisteredResources` handler wired to call mapper and pass params
to sqlc query
- No new constants needed — `sortFieldName`, `sortFieldCreatedAt`,
`sortFieldUpdatedAt` already exist

**Tests**
- 11 unit tests for the enum mapper helper (nil, empty, unspecified,
each field + direction, unspecified direction default)
- 7 integration tests (name ASC/DESC, created_at ASC/DESC, updated_at
ASC/DESC, unspecified fallback) using
`createSortTestRegisteredResources` and
`createNamedSortTestRegisteredResources` suite helpers
- Protovalidate sort constraint test
(`TestListRegisteredResourcesRequest_Sort`)

### Notes

- otdfctl `--sort` flag deferred to a follow-up, consistent with #3192,
#3223, #3255, #3272, and #3300
- Tie-breaker (`r.id ASC`) deferred to a follow-up refactoring ticket

### Checklist

- [x] I have added or updated unit tests
- [x] I have added or updated integration tests (if appropriate)
- [x] I have added or updated documentation

### Testing Instructions



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Added sorting functionality to registered resources lists. Sort by
name, creation date, or update date in ascending or descending order.
Defaults to creation date (descending) when not specified.

* **Documentation**
* Updated API documentation with new sorting options and default
ordering behavior.

* **Tests**
* Added integration and unit tests covering all sorting configurations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants