Skip to content

OSS-169: accept hydradb-sdk>=2.1.7,<3 so installing the CLI no longer downgrades the SDK - #60

Open
adityamishra-hydradb wants to merge 2 commits into
mainfrom
adityamishra/oss-169-sdk-range
Open

adityamishra-hydradb wants to merge 2 commits into
mainfrom
adityamishra/oss-169-sdk-range

Conversation

@adityamishra-hydradb

@adityamishra-hydradb adityamishra-hydradb commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

For humans

Installing the CLI pinned one SDK version exactly (hydradb-sdk==2.1.7 on main, ==2.1.2 in the 0.2.0 release). When a project already had a newer SDK, pip replaced it with the old one without a question, and uv refused the install. This PR changes the pin to the range hydradb-sdk>=2.1.7,<3.

A range alone was not enough. The CLI failed on SDK 2.1.8 (64 tests failed), because 2.1.8 changed three things the wrapper used. This PR fixes all three in the wrapper, so the CLI works on 2.1.7 and on 2.1.8:

  1. 2.1.8 has no app_knowledge keyword on context.ingest. The API still reads that form field. The wrapper now sends it as an extra form field when the SDK has no keyword for it.
  2. 2.1.8 renamed the body keyword of the credential-rotation method (request= became refresh_token=). The wrapper now sends the same credentials body on both.
  3. 2.1.8 makes more response fields required. A 2xx answer without them raised an error. The wrapper now reads such an answer as plain JSON, as it did on 2.1.7.

CI now also runs the tests on the floor of the range (2.1.7). The normal test job gets the newest 2.x.

Follow-ups (not in this PR):

  • Release. No release is published here. A release that carries this fix (0.2.4) is a follow-up, together with OSS-71 (0.2.0 lags main).
  • CONTRACT.md §2 rule 1 still says "exact SDK pin". That file is a shared master copy for four repos and must not change in one repo alone. The rule needs one change across hydradb-cli and hydradb-mcp (and the Group 1 plugins).

Fixes OSS-169.

For agents

  • pyproject.toml: hydradb-sdk==2.1.7 -> hydradb-sdk>=2.1.7,<3. Floor 2.1.7 because the wrapper is tested on it; older 2.1.x were not checked.
  • src/hydradb_cli/hydra/client.py:
    • _split_body(fn, body): fields fn names as parameters go as keywords; the rest go to request_options["additional_body_parameters"], which Fern merges into the JSON body or the multipart form on 2.1.7 and 2.1.8 (same get_request_body code in both).
    • _invoke_write(..., extra_body=) merges that with max_retries: 0.
    • _invoke: a ParsingError with a 2xx status and a dict body returns the body (envelope -> object with data/success/meta), so _unwrap and _request_id_of work unchanged. Non-2xx or non-dict bodies still raise HydraDBClientError.
    • context.ingest: app_knowledge goes through _split_body.
    • connectors.rotate_credentials: request= when the SDK has it; otherwise _split_body, and a required keyword the credentials lack is passed as ... (Fern OMIT), so the JSON body is exactly the credentials.
  • .github/workflows/ci.yml: new job test-sdk-floor reads the floor from pyproject.toml and runs pytest -q on it.
  • Not touched: stdin, kinds and error-message code paths (OSS-152, OSS-168, OSS-155 are in progress in another PR).

Proof

A = base main @ 5a5842d (hydradb-sdk==2.1.7) · B = this PR @ ed1ec15 (hydradb-sdk>=2.1.7,<3). Run 2026-12-04 22:40-22:50 UTC. Raw output: ~/hydradb/dogfood/sdk/proof/oss-169/ (pin_ab.txt, smoke_218.txt, tests_A.txt, tests_B.txt).

1. A/B on the real repro: install the CLI next to SDK 2.1.8

Clean venvs (Python 3.12), hydradb-sdk==2.1.8 installed first, then the CLI wheel built from each commit (uv build --wheel). Command for pip: pip install <cli wheel>. Command for uv: uv pip install hydradb-sdk==2.1.8 <cli wheel>.

Check A (base @5a5842d) B (PR @ed1ec15)
Wheel Requires-Dist hydradb-sdk==2.1.7 hydradb-sdk<3,>=2.1.7
pip: SDK before -> after 2.1.8 -> 2.1.7 (Found existing installation: hydradb-sdk 2.1.8 ... Successfully uninstalled hydradb-sdk-2.1.8) 2.1.8 -> 2.1.8 (Requirement already satisfied: hydradb-sdk<3,>=2.1.7 ... (2.1.8))
pip: HydraDB(...).byog present after install False (lost with the downgrade) True
uv exit 1: hydradb-cli==0.2.3 depends on hydradb-sdk==2.1.7 ... your requirements are unsatisfiable exit 0: installs hydradb-cli==0.2.3, SDK stays 2.1.8

2. A/B: the CLI on SDK 2.1.8, against prod

Own database dogfood-fix-oss-169 in our test org (deleted after). A = base CLI with SDK 2.1.8 forced in (uv pip install --no-deps hydradb-sdk==2.1.8), which is what the range lets users get. B = PR CLI, SDK 2.1.8 resolved by pip.

Command (-o json) A (base @5a5842d) on SDK 2.1.8 B (PR @ed1ec15) on SDK 2.1.8
ingest --kind knowledge --text ... --source-id k-X rc=1, traceback: TypeError: ContextClient.ingest() got an unexpected keyword argument 'app_knowledge' rc=0, Knowledge uploaded successfully
ingest --kind memory --text ... rc=0 rc=0
ingest <file> rc=0, 1 queued rc=0, 1 queued
database stats / database readiness rc=0 / rc=0 rc=0 / rc=0
list --kind knowledge rc=0, total 0 (the text item never got in) rc=0, total 2
query "Who owns the zephyr ledger?" rc=0, chunks: [] rc=0, chunk with app_external_id: k-B, app_kind: knowledge_base
delete k-X --kind knowledge -y rc=1, Nothing deleted: no matching knowledge source(s) for k-A rc=0, deleted_count: 1, id k-B

3. Regression: full test suite (pytest -q), on both SDK releases

SDK installed A (base @5a5842d) B (PR @ed1ec15)
2.1.7 (floor) 1958 passed, 133 skipped 1971 passed, 133 skipped
2.1.8 (newest) 64 failed, 1894 passed, 133 skipped 1971 passed, 133 skipped

The 64 A failures on 2.1.8 (list: A_on_2.1.8_failures.txt): 55 are the app_knowledge keyword (every knowledge-text ingest path in the sim, wrapper and conformance tests), 1 is the rotate-credentials request= keyword, and 8 are stricter 2.1.8 response models that refuse a 2xx body (ParsingError on databases.create/delete/status/stats and connectors.delete_resource). B adds 13 tests. ruff check . and ruff format --check . pass. CI on B: test (3.10-3.13) (newest SDK) and the new test-sdk-floor (2.1.7) are green.

4. Smoke

Section 2, column B, is the smoke run: ingest (text, memory, file), database stats and readiness, list, query, delete, all on SDK 2.1.8 against prod.

5. Stress / load

N/A: the change is to dependency resolution and request building, not to limits, concurrency or batching.

6. Edge cases the change targets

Case Test B result
SDK has no app_knowledge keyword: field still reaches the multipart form TestSdkRangeCompat::test_app_knowledge_reaches_the_form_when_the_sdk_has_no_keyword pass on 2.1.7 and 2.1.8
Rotate credentials, 2.1.8 signature (refresh_token=): body is the whole credentials object test_sends_the_same_body_when_the_sdk_names_one_field, test_installed_sdk_sends_the_credentials_as_the_body pass
Credentials hold id or request_options (Devin finding) test_credential_fields_named_like_call_arguments_stay_in_the_body pass
Credentials lack the field 2.1.8 requires: field left out, not invented test_a_required_field_the_credentials_lack_is_omitted_not_invented pass
2xx body that the generated model refuses: read as JSON (envelope or bare) test_a_2xx_body_the_response_model_rejects_is_returned_unwrapped, test_a_2xx_bare_body_is_returned_as_is pass
ParsingError on a 5xx, or on a non-object 2xx body: still an error test_a_parsing_error_on_an_error_status_still_raises, test_a_2xx_body_that_is_not_an_object_still_raises pass
pyproject.toml keeps a range test_the_sdk_dependency_is_a_range_not_an_exact_pin pass

🤖 Generated with Claude Code

The exact pin made pip downgrade a user's newer SDK and uv refuse the
install. Accept any 2.x from 2.1.7 up, and make the wrapper work on
2.1.8: send app_knowledge as an extra form field when the SDK has no
keyword for it, keep the rotate-credentials body the same when the SDK
renames its keyword, and read a 2xx answer that a stricter generated
response model rejects as plain JSON. CI runs the tests on the floor too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

@hydra-mira-review review

@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

@hydra-mira-review

hydra-mira-review Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Mira score 5/5 · 🟢 Good to merge

  • No findings in the code.
  • Read these high-risk changes closely: Preserve knowledge ingestion when the SDK drops a keyword, Keep the credentials body intact across SDK signatures and 1 more.

Installing the CLI now allows newer compatible SDK versions without forcing a downgrade. The PR broadens the dependency range, adapts SDK calls and response handling, and adds compatibility coverage.

How this PR works · 5 changes, 3 high risk, 1 medium risk, 1 low risk

Installing the CLI could downgrade an existing SDK or cause a dependency conflict. This PR accepts hydradb-sdk>=2.1.7,<3 and adapts the wrapper to three SDK changes introduced in 2.1.8. CI also gains a job for the oldest supported SDK.

1. Allow compatible SDK versions instead of forcing a downgrade · 🟠 medium risk · pyproject.toml

Installing the CLI can retain a newer compatible SDK. The dependency changes from hydradb-sdk==2.1.7 to hydradb-sdk>=2.1.7,<3.

Risk: An incompatible SDK release can make installed CLI commands fail when they construct requests or read responses.

Check:

  • Install alongside an existing 2.1.8 dependency and confirm pip and uv retain a compatible SDK.

In pyproject.toml:35-40.

2. Preserve knowledge ingestion when the SDK drops a keyword · 🔴 high risk · src/hydradb_cli/hydra/client.py

Knowledge text can still reach the API when the SDK removes its keyword. Previously, ingestion always passed app_knowledge directly; now _Context.ingest adapts to the SDK signature.

Risk: Incorrect form assembly can lose knowledge content, source IDs, or access restrictions when users ingest text.

Check:

  • Compare multipart forms on 2.1.7 and 2.1.8 using knowledge text with a source ID and ACL.
  • Confirm write requests still set max_retries: 0.

How it works:

  1. _split_body separates recognized keyword-only fields from extra body fields, excluding positional arguments and request_options.
  2. _invoke_write adds extras through additional_body_parameters while retaining max_retries: 0.
  3. _Context.ingest sends the existing serialized knowledge item through whichever path the installed SDK supports.

What it touches:

  • src/hydradb_cli/commands/_impl.py::do_ingest_knowledge_text.
  • src/hydradb_cli/commands/_impl.py::do_ingest_memory.
  • src/hydradb_cli/commands/_impl.py::do_ingest_knowledge_files.
  • src/hydradb_cli/hydra/client.py::_Connectors.rotate_credentials.
  • hydradb ingest --kind knowledge --text ....
  • Memory and file ingestion share the modified write helper.
  • The multipart form retains app_knowledge, including the item's source ID and ACL; the intended wire format stays unchanged.

In client.py:142-165, client.py:207-223, client.py:465-480.

3. Keep the credentials body intact across SDK signatures · 🔴 high risk · src/hydradb_cli/hydra/client.py

Credential rotation keeps sending the complete credentials object. Previously, it always used request=; now _Connectors.rotate_credentials also handles SDK methods that name individual body fields.

Risk: An incorrectly assembled replacement body can overwrite stored credentials with incomplete values and stop connector synchronization.

Check:

  • Compare outgoing JSON on both SDK versions with refresh_token, client_id, id, and request_options credentials.
  • Confirm credentials containing only access_token do not gain an invented refresh_token.

How it works:

  1. rotate_credentials retains request=credentials when the SDK declares that parameter.
  2. Otherwise, _split_body separates named credential fields from extra JSON fields.
  3. Missing required keyword-only arguments receive ..., the SDK omission value, before _invoke_write sends the request.

What it touches:

  • src/hydradb_cli/commands/connectors.py::rotate_credentials.
  • hydradb connectors rotate-credentials.
  • /connectors/{connector_id}/credentials.
  • The credentials JSON remains the complete replacement body, including fields named id or request_options; missing fields are omitted.

In client.py:1034-1052.

4. Read successful responses that stricter SDK models reject · 🔴 high risk · src/hydradb_cli/hydra/client.py

Successful API responses remain readable when a newer SDK rejects their shape. Previously, _Resource._invoke translated every ParsingError; now it accepts dictionary bodies only for 2xx statuses.

Risk: Incorrect envelope recognition can silently change query output or make a completed write appear to have returned the wrong result.

Check:

  • Check rejected 2xx envelopes, bare dictionaries, non-dictionary bodies, and error statuses.
  • Confirm a rejected query envelope still exposes meta.request_id in CLI output.

How it works:

  1. _invoke passes qualifying dictionary bodies to _raw_response.
  2. _raw_response converts envelope-shaped dictionaries into objects that existing payload and request-ID readers understand.
  3. Other parsing failures still become HydraDBClientError.

What it touches:

  • src/hydradb_cli/hydra/client.py::_Resource._invoke_write.
  • src/hydradb_cli/hydra/client.py::_Databases.list.
  • src/hydradb_cli/hydra/client.py::_Context.query.
  • src/hydradb_cli/hydra/client.py::_Context.list.
  • src/hydradb_cli/hydra/client.py::_Connectors.get.
  • SDK-backed database, context, and connector commands.
  • hydradb query without title filters.
  • Previously rejected responses become CLI payloads; envelope metadata remains available for query request IDs.

In client.py:131-139, client.py:194-206.

5. Supporting changes · 🟢 low risk · .github/workflows/ci.yml +3

CI now checks the oldest supported SDK alongside normal dependency resolution. Tests cover request preservation and response fallbacks, while documentation describes the range.

Risk: A broken floor job can block merges or leave the minimum supported SDK unchecked.

Check:

  • Confirm the floor extraction selects 2.1.7 and the existing test matrix retains unconstrained resolution within the declared range.

In ci.yml:52-70, test_wrapper.py:582-746, CHANGELOG.md:9-11 and 1 more.

Requirement check · 5 met, 2 for another PR · from the PR description
  • ✅ Accept hydradb-sdk>=2.1.7,<3 instead of an exact pin (met). pyproject.toml declares the requested range.
  • ✅ Keep sending app_knowledge when the SDK no longer accepts that keyword (met). _Context.ingest uses _split_body, and _invoke_write forwards unsupported fields through additional_body_parameters.
  • ✅ Preserve the credentials body across the request= and refresh_token= SDK signatures (met). _Connectors.rotate_credentials branches on the signature, preserves extra fields, and supplies omission values for absent required keywords.
  • ✅ Read dictionary responses rejected by stricter models only when their HTTP status is successful (met). _Resource._invoke accepts dictionary bodies for 2xx parsing failures and translates all other parsing failures.
  • ✅ Configure CI for both the supported floor and normal newest-compatible SDK resolution (met). .github/workflows/ci.yml adds test-sdk-floor; the existing test matrix installs the package without an SDK override.
  • ➖ Publish a release carrying the installation fix (for another PR). The description assigns release 0.2.4 to follow-up work with OSS-71; pyproject.toml remains at 0.2.3.
  • ➖ Update the shared contract's exact-pin rule across clients (for another PR). The description explicitly defers the coordinated contract update across the CLI, MCP, and plugins.
Diagram of the changed files
graph LR
  ci[".github/workflows/ci.yml"] --> config["pyproject.toml"]
  ci --> tests["tests/test_wrapper.py"]
  tests --> client["src/hydradb_cli/hydra/client.py"]
Loading
⚠️ Other open PRs change the same code · 5

Merge them in order, or check that they agree.

  • #61 (merge-conflict risk). Batching file ingestion and adapting context.ingest arguments for SDK compatibility both change ingest request construction in client.py. Shared: CHANGELOG.md, src/hydradb_cli/hydra/client.py
  • #39 (merge-conflict risk). Moving wrapper calls to typed SDK 2.1.6 interfaces overlaps the SDK call adaptations and dependency requirement changed by OSS-169: accept hydradb-sdk>=2.1.7,<3 so installing the CLI no longer downgrades the SDK #60. Shared: CHANGELOG.md, pyproject.toml, src/hydradb_cli/hydra/client.py
  • #30 (merge-conflict risk). Adding unified item ingestion changes the same ingest wrapper behavior that OSS-169: accept hydradb-sdk>=2.1.7,<3 so installing the CLI no longer downgrades the SDK #60 adapts for SDK 2.1.8. Shared: CHANGELOG.md, src/hydradb_cli/hydra/client.py
  • #38 (merge-conflict risk). Branching wrapper requests by database layout overlaps the ingest request construction changed for SDK compatibility. Shared: CHANGELOG.md, src/hydradb_cli/hydra/client.py
  • #46 (merge-conflict risk). Unified routing changes overlap the ingest wrapper calls being adapted for SDK 2.1.8. Shared: CHANGELOG.md, src/hydradb_cli/hydra/client.py, tests/test_wrapper.py

Comment @hydra-mira-review help for commands.

devin-ai-integration[bot]

This comment was marked as resolved.

Only keyword-only SDK parameters count as body fields. A path argument
(id) and request_options are not, so a credentials object that holds
either key is sent as it is instead of crashing the call on SDK 2.1.8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityamishra-hydradb <[email protected]>
@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

@hydra-mira-review review

@adityamishra-hydradb

Copy link
Copy Markdown
Contributor Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

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.

1 participant