Skip to content

fix(flow): refuse queried non-searchset bundles in bundle() as complete reads - #2163

Open
yunusarda-sudo wants to merge 1 commit into
OpenAdaptAI:mainfrom
yunusarda-sudo:fix/ensure-record-bundle-parameterized-non-searchset
Open

yunusarda-sudo wants to merge 1 commit into
OpenAdaptAI:mainfrom
yunusarda-sudo:fix/ensure-record-bundle-parameterized-non-searchset

Conversation

@yunusarda-sudo

Copy link
Copy Markdown
Contributor

Resolves #2108.

Context & Problem

In #2098, the FHIR collection reader was updated to refuse queried collection bundles as complete reads (verifying that no query is present across configured parameters, requested and effective URLs, and self-links).

However, as reported in #2108, the sibling reader in openadapt_flow/ensure_record.py (FhirReader.bundle()) still accepted any non-searchset bundle without a next link as complete even when query parameters were sent or present on the URL/self-link, allowing a capped or filtered read to count as a full read.

Solution

  • openadapt_flow/fhir_read.py: Export check_collection_url (aliasing _check_collection_url for backwards compatibility).
  • openadapt_flow/ensure_record.py (FhirReader.bundle):
    • Track initial_url and unpack headers from fetch.
    • When a bundle is not a searchset or history bundle and has no next link (if not nxt), apply the collection refusal rule:
      • Refuse if configured params are present.
      • Refuse if initial_url contains a query.
      • Refuse if the effective served URL (Content-Location or Location header) contains a query.
      • Refuse if any relation: "self" link contains a query.
    • Raise Unreadable(f"{path}: {exc}") on any violation.
  • packages/flow/tests/test_ensure_record.py:
    • Add regression test test_bundle_refuses_parameterized_non_searchset_bundle covering configured params, query in path, query in self-link, query in effective URL (content-location), unqueried collection acceptance, and normal parameterized searchset pagination/coverage.

Verification

  • PYTHONPATH=packages/flow pytest packages/flow/tests/test_ensure_record.py -q: 112/112 passed.
  • PYTHONPATH=packages/flow pytest packages/flow/tests/test_page_snapshot_consistency.py -q: 82/82 passed.
  • ruff check and ruff format --check: clean.

…te reads (OpenAdaptAI#2108)

Signed-off-by: Yunus Ardaguney <yunusarda-sudo@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

ensure_record bundle() treats a parameterized non-searchset bundle without a next link as complete

1 participant