Repository navigation
chore: regenerate SDK from current public API schema - #20
Conversation
Copy public_api.swagger.json from tkhq/sdk at commit 7b456b03513cef96dbc17dc6ed36cc55b9212f0e (packages/sdk-types/src/__inputs__/public_api.swagger.json, last changed in 5e732215f1271d05a495e6c45ed77cd689383425). The schema now has 173 activity types (was 121) and 189 endpoints (was 114). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The new schema breaks the HTTP generator in three ways: - validateTvcImage is a query (/public/v1/query/), but its name does not start with get, list or test. The generator treated it as an activity and crashed with KeyError: 'ValidateTvcImageResult'. Names that start with "validate" are now queries. The TS SDK codegen does the same. - The client built the activity type from the method name. For eth_send_transaction, sol_send_transaction, create_swap_quote, execute_swap and create_oauth_providers it sent the unversioned type with a newer intent body. For eth_undelegate_7702 it sent ACTIVITY_TYPE_ETH_UNDELEGATE7702, which does not exist. The generator now reads the type from the request definition, like the TS SDK codegen. Pins in VERSIONED_ACTIVITY_TYPES still take precedence. - The client always used the latest result key, even when the activity type is pinned. create_sub_organization is pinned to V7, but the schema now has a V8 result, so V7 results were not unpacked. The generator now uses the pinned result type, as the types generator already does. Generating from the previous schema gives the same output as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Output of `make generate` against the updated public API schema. No hand edits to generated files. - 114 to 189 API methods (each with a stamp_ variant). Nothing removed. - New: send transaction V2, swaps, earn, secrets, transaction history, TVC, MFA policies, webhooks, IP allowlist, session profiles, Spark. - eth_send_transaction and sol_send_transaction now use the V2 intents. test_pydantic_aliases builds EthSendTransactionBody. It now uses the V2 shape (`calls` replaces `to`). The test still checks the `from` alias. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ruff 0.17 formats Python code blocks inside Markdown, so make format-check fails on three READMEs that have not changed since March. This fails on main too. Excluding *.md keeps the check on code only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Documented public API breaking changes and limited integration validation warrant human compatibility review.
No open issues 🎉
What changed in this PR
Updates code generation to support the current Turnkey public API schema and newer SDK request shapes.
Changes:
- Reads activity types from the schema, preserves pinned results, and recognizes validation queries.
- Updates alias tests for Ethereum transaction V2.
- Excludes Markdown from Ruff and adds a minor-release changeset.
| File | Description |
|---|---|
pyproject.toml |
Excludes Markdown from Ruff formatting. |
packages/sdk-types/tests/test_pydantic_aliases.py |
Updates alias tests to use V2 transaction calls. |
codegen/utils.py |
Classifies validation methods as queries. |
codegen/http/generate_http.py |
Resolves schema activity types and pinned result keys. |
.changeset/codegen-bump-2026-10.yml |
Records minor releases for HTTP and SDK types. |
Review effort: Balanced
Adversarial reviewI approached this as "assume the regen is wrong and try to prove it." Most of the attack failed; details at the bottom. Two things survived, one of which is a regression in an existing public code path. Setup used for everything below: fresh clone at
Verdict: Merge after fixes — finding 1 blocks (or land Attacked but held:
Review provenanceHuman asked about:
Answered by: automated review, run and checked locally by the commenter |
send_signed_request found the result to flatten by scanning dir(result) for names ending in Result, so a completed eth_send_transaction, sol_send_transaction, or create_oauth_providers (keys ending in ResultV2) came back with nothing flattened and a typed response failed validation. It now flattens whichever result field is set. The default polling budget was 3 retries at 1 second. Send, swap, earn, and TVC activities often take longer, so the default is now 10 retries at 1 second. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ion drift CREATE_OAUTH_PROVIDERS, ETH_SEND_TRANSACTION, and SOL_SEND_TRANSACTION are pinned to V2, the versions this regen moved them to. codegen/activity_versions.json records the activity type every method sends; make generate-http stops when a method would move and says how to pin it or accept the move. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
(see above) |
Summary
This PR regenerates the Python SDK from the current Turnkey public API schema.
7b456b03513cef96dbc17dc6ed36cc55b9212f0e, filepackages/sdk-types/src/__inputs__/public_api.swagger.json. That file last changed in5e732215f1271d05a495e6c45ed77cd689383425. The repo has no convention for recording the source sha in the schema, so this PR does not add one.stamp_variant. No method or type was removed.Commits
chore: update public API schema from tkhq/sdk. This commit only replaces the schema file.fix(codegen): handle the current public API schema in the HTTP generator. This is a small fix incodegen/. Without it,make generatefails on the new schema. See "Generator changes" below.chore: regenerate SDK types and HTTP client. This is the output ofmake generate, with one test update.chore: add changeset for the codegen bump. This adds aminorchangeset forhttpandsdk-types.How it was generated
make installmake generate(this runsgenerate-typesand thengenerate-http)make format. This also reformats Python code blocks in three README files. That happens onmaintoo, because newer ruff formats Markdown. I left those README changes out of this PR.Generator changes
On the new schema,
make generate-httpfailed withKeyError: 'ValidateTvcImageResult'. Fixing only the crash would still leave a client that sends incorrect activity types. The fix is incodegen/utils.pyandcodegen/http/generate_http.pyonly. Generated files have no hand edits.validateTvcImageis a query endpoint, but its name does not start withget,list, ortest. The generator classified it as an activity. Names that start withvalidateare now queries. The TS SDK codegen does the same.eth_send_transaction,sol_send_transaction,create_swap_quote,execute_swap, andcreate_oauth_providers, the client would have sent the old unversioned type with the new intent body. Foreth_undelegate7702, it would have sentACTIVITY_TYPE_ETH_UNDELEGATE7702, which does not exist. The generator now reads the type from the request definition, as the TS SDK codegen does. The pins inVERSIONED_ACTIVITY_TYPESstill take precedence.create_sub_organizationis pinned to V7, but the schema now has a V8 result. Without this fix, a completed V7 activity would not unpack its result. The generator now uses the pinned result type, as the types generator already does.I generated again from the old schema with the new codegen. The output is identical to
main.Activity versions sent
eth_send_transactionACTIVITY_TYPE_ETH_SEND_TRANSACTION_V2sol_send_transactionACTIVITY_TYPE_SOL_SEND_TRANSACTION_V2create_swap_quoteACTIVITY_TYPE_CREATE_SWAP_QUOTE_V3execute_swapACTIVITY_TYPE_EXECUTE_SWAP_V3earn_depositACTIVITY_TYPE_EARN_DEPOSITearn_withdrawACTIVITY_TYPE_EARN_WITHDRAWinit_import_secretsACTIVITY_TYPE_INIT_IMPORT_SECRETSexport_secretsACTIVITY_TYPE_EXPORT_SECRETScreate_sub_organizationACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7(pinned, no change)create_usersACTIVITY_TYPE_CREATE_USERS_V3(pinned, no change)These methods are queries:
get_swap_status,list_earn_enabled_vaults,list_earn_positions,list_eth_transaction_history,list_sol_transaction_history,validate_tvc_image.Testing
make typecheck: passes onmainand on this branch.make format-check: fails onmainand on this branch for the same three README files. The cause is newer ruff, which formats Markdown code blocks. All Python files pass.make test, offline:packages/sdk-types/tests/test_pydantic_aliases.pypasses. The test buildsEthSendTransactionBody. I changed it to use the V2 shape (calls=[{"to": ...}]replacesto=...). It still checks thefromalias.packages/http/testsneed live credentials (tests/.env, seetests/.env.example). I did not run them against the API. Without credentials they fail the same way onmainand on this branch. They fail, they do not skip. The tests aretest_create_api_keys,test_organization_id_override,test_stamp_create_api_keys_send_signed_request,test_get_whoami,test_get_organization,test_get_users, andtest_get_wallets.conftest.pyimportsdotenv, butpython-dotenvis not in any dev dependency list. I installed it by hand.TurnkeyClientand confirmed that the 13 new methods above exist with typed bodies.stamp_*methods to read the activity type each method sends (see the table).requests.postmocked, theX-Client-Versionheader is stillturnkey-python/0.1.0fromversion.py.requests.postmocked, a completed V2 send transaction and a completed V7 sub-organization both unpack their result fields.Breaking changes for existing callers
EthSendTransactionBodynow uses the V2 intent.to,value, anddataare gone.calls: List[v1EthCallParams]is required.SolSendTransactionBodynow uses the V2 intent.signWithis gone.signWiths: List[str]is required.CreateOauthProvidersBody.oauthProvidersis nowList[v1OauthProviderParamsV2], and the method sends V2.Oauth2AuthenticateBody.nonceis now required.v1User.mfaPoliciesis now a required response field. Responses that do not include it fail validation.v1FiatOnRampBlockchainNetworkno longer hasFIAT_ON_RAMP_BLOCKCHAIN_NETWORK_BITCOIN.v1CreateTvcDeploymentIntentdropspivotBindAddressesand requireshealthCheckType,healthCheckPort, andpublicIngressPort.The packages are still 0.x, so the changeset uses
minor. Reviewers can change this tomajorif they prefer.Follow-ups
Tracked outside this PR:
FAILED,REJECTED, orCONSENSUS_NEEDED; the generic submit path does not unpack...V7result keys; validation errors subclassValueErrorand mask both. Fixed in fix(http): raise TurnkeyActivityError when an activity does not complete #21, stacked on this PR.make format-checkfailed on README code blocks with current ruff. Fixed here by excluding Markdown from ruff format (commit e4455e0).CREATE_SUB_ORGANIZATIONto V8 andCREATE_USERSto V4 to match the TypeScript SDK: Bump CREATE_SUB_ORGANIZATION to V8 and CREATE_USERS to V4 #23.eth_send_transactionandsol_send_transactionnext to the V2 methods: Decide whether to keep V1 eth_send_transaction and sol_send_transaction methods #24.python-dotenvto the http dev dependencies and make the live tests skip without credentials: Add python-dotenv to the http dev dependencies and make live tests skip without credentials #25.main. Add pytest and run on every PR: CI: run pytest, and run the build workflow on every pull request #26.codegen/http/generate_http.pyand the generated client. Whichever PR merges second must rebase and runmake generateagain.🤖 Generated with Claude Code