Skip to content

Conversation

@k1bs
Copy link
Collaborator

@k1bs k1bs commented Feb 3, 2026

Adds support for the POST /api/programs/:program_id/members/search endpoint.

Invalid param combinations raise ArgumentError.

  • Returns max 10 results with more_results flag (no pagination)

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added search for program members with bounded results (max 10) and a more_results indicator; supports multiple valid parameter combinations.
  • Documentation

    • Added README section with usage examples, valid parameter combinations, and pagination notes.
  • Tests

    • Added integration tests covering successful searches and invalid-parameter errors, plus recorded HTTP cassettes for search scenarios.
  • Tests (support)

    • VCR configured to allow repeated playback of recorded cassettes.

Walkthrough

Adds a new Programs#search_members API to perform bounded member searches with validated parameter combinations, updates README with usage and pagination notes, adds VCR cassettes for recorded search responses, and adds integration tests covering valid/invalid search parameter scenarios.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added "Search Members" section describing search_members usage, allowed parameter combinations, examples, 10-result limit and more_results flag, and permission notes.
Implementation
lib/data_nexus/resources/programs.rb
Added VALID_SEARCH_COMBINATIONS constant, public search_members(**params) method, and private helpers validate_search_params!(params) and invalid_search_params_message(provided_keys) to enforce allowed parameter sets and send POST to search endpoint.
Test Fixtures (VCR cassettes)
spec/cassettes/program_members/search_employee_id.yml, spec/cassettes/program_members/search_name.yml, spec/cassettes/program_members/search_prefix.yml
Added three cassettes recording POST /programs/:id/members/search interactions and 200 responses for employee_id+DOB, name+DOB, and prefix+DOB search variants.
Tests
spec/integration/program_members_spec.rb
Added "searching members" integration tests covering successful searches (employee_id, full name, prefixes) and error cases for invalid/mixed/insufficient parameter combinations.
Test config
spec/support/vcr.rb
Enabled allow_playback_repeats: true in VCR default cassette options to permit repeated playback within cassettes.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Caller
    participant Lib as ProgramsResource
    participant API as DataNexusAPI

    rect rgba(200,230,255,0.5)
    Client->>Lib: search_members(params)
    Lib->>Lib: validate_search_params!(params)
    end

    rect rgba(200,255,200,0.5)
    Lib->>API: POST /api/programs/:id/members/search (body: params)
    API-->>Lib: 200 OK (data, more_results)
    Lib-->>Client: return parsed response (hash with :data and :more_results)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 4763: #1: Modifies the Programs resource (lib/data_nexus/resources/programs.rb); likely related to member handling and method surface in the same class.

Suggested reviewers

  • fastjames
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Title check ✅ Passed The title 'K1bs/4902/add search route' refers to adding a search route, which aligns with the main changeset that introduces a search_members capability to the Programs resource.
Description check ✅ Passed The description accurately describes the changeset: adds support for a POST search endpoint, enforces parameter validation via ArgumentError, and documents the 10-result limit with more_results flag behavior.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch k1bs/4902/add-search-route

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

Copy link

@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

🤖 Fix all issues with AI agents
In `@spec/integration/program_members_spec.rb`:
- Around line 79-113: The tests are failing because API responses are parsed
with string keys while callers expect symbol keys; update the connection layer
to return symbolized keys by modifying the response parsing in the
Connection#post (and any other request methods) to convert parsed JSON to symbol
keys (e.g., use JSON.parse with symbolize_names: true or call
deep_symbolize_keys on the parsed hash) so that callers can use result[:data]
and result[:more_results]; alternatively, if you prefer tests change, update the
spec expectations to use string keys ("data"/"more_results") everywhere instead
of symbols.

Copy link

@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: 2

🤖 Fix all issues with AI agents
In `@spec/cassettes/program_members/search_employee_id.yml`:
- Around line 40-48: The cassette contains JSON string values that are split
across lines (e.g., the fields first_name, street_address_1, and
health_plan_coverage_tier), which can inject newlines/whitespace into parsed
values; fix by re-recording or normalizing the cassette so all JSON string
values are single-line (join the broken lines or escape newline characters) for
the affected entries (look for the member objects containing first_name,
street_address_1, health_plan_coverage_tier and employee_id placeholders) to
ensure compact, valid JSON strings.
- Around line 40-51: The cassette contains real PII in JSON fields (email,
phone_number, first_name, last_name, street_address_1, city, postal_code) —
replace those values with generic placeholders (e.g. "<EMAIL>", "<PHONE>",
"<FIRST_NAME>", "<LAST_NAME>", "<ADDRESS>", "<CITY>", "<POSTAL>") throughout the
cassette string and add corresponding filter_sensitive_data rules to your test
VCR/config so those keys (email, phone_number, first_name, last_name,
street_address_1, city, postal_code) are scrubbed automatically on record;
search for the JSON keys "email", "phone_number", "first_name", "last_name",
"street_address_1", "city", and "postal_code" in the cassette and update values
and VCR filters accordingly.
🧹 Nitpick comments (1)
spec/support/vcr.rb (1)

21-24: Scope allow_playback_repeats to targeted cassettes to keep tests strict.

Making repeats global can hide accidental extra requests; with match_requests_on: %i[method path], different POST bodies may also replay the same response. Consider enabling repeats only for specific cassettes or adding body matching where necessary.

@k1bs k1bs requested a review from fastjames February 3, 2026 21:44
@k1bs
Copy link
Collaborator Author

k1bs commented Feb 4, 2026

[sc-4902]

Copy link

@fastjames fastjames left a comment

Choose a reason for hiding this comment

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

🍰

@k1bs k1bs merged commit b1df05c into main Feb 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants