Skip to content

fix(order-book): uploadAppData returns AppDataHash, not AppDataObject - #968

Open
gomesalexandre wants to merge 1 commit into
cowprotocol:mainfrom
gomesalexandre:fix_upload_appdata_return_type
Open

fix(order-book): uploadAppData returns AppDataHash, not AppDataObject#968
gomesalexandre wants to merge 1 commit into
cowprotocol:mainfrom
gomesalexandre:fix_upload_appdata_return_type

Conversation

@gomesalexandre

@gomesalexandre gomesalexandre commented Aug 15, 2026

Copy link
Copy Markdown

Closes #193

OrderBookApi.uploadAppData() is typed as returning Promise<AppDataObject>. It doesn't - the orderbook returns the appDataHash, a plain hex string.

Straight from the OpenAPI spec this package pins its own codegen to (services@5341875), PUT /api/v1/app_data/{app_data_hash}:

responses:
  "200":
    description: The full `appData` already exists.
    content:
      application/json:
        schema:
          $ref: "#/components/schemas/AppDataHash"
  "201":
    description: The full `appData` was successfully registered.
    content:
      application/json:
        schema:
          $ref: "#/components/schemas/AppDataHash"

And AppDataHash is type: string, while AppDataObject is an object with a fullAppData property. So it's not a doc nit, the return type is just wrong.

The funny part is our own test already knew. api.spec.ts mocks a bare string and asserts the result equals the hash - it even names the variable appDataHashResult. Only the type disagreed.

what changed

  • uploadAppData now returns Promise<AppDataHash>
  • fixed the @returns docblock, it claimed "the string encoding of the full app data"
  • pinned the return type in the existing test so a regression fails tsc instead of surviving until someone hits it at runtime

No consumer needed touching. Every call site in trading/ and bridging/ already ignores the return value, and the mocks resolve strings or undefined.

receipts

Reverting just the return type to AppDataObject, leaving the new assertion in place:

$ pnpm typecheck
src/api.spec.ts(689,11): error TS2322: Type 'AppDataObject' is not assignable to type 'string'.

With the fix:

$ pnpm typecheck
$ tsc --noEmit
(exit 0)
$ pnpm test
PASS src/signingSchemes.test.ts
PASS src/quoteAmountsAndCosts/getProtocolFeeAmount.test.ts
PASS src/transformOrder.test.ts
PASS src/quoteAmountsAndCosts/getQuoteAmountsAndCosts.test.ts
PASS src/request.test.ts
PASS src/api.spec.ts

Test Suites: 6 passed, 6 total
Tests:       64 passed, 64 total

risk

Low, but it is a breaking type change on a public method - anyone who wrote const { fullAppData } = await uploadAppData(...) was already getting undefined at runtime, they just weren't told. Happy to land it behind a major if you'd rather.

Summary by CodeRabbit

  • Bug Fixes
    • Updated app data uploads to return the registered app data hash.
    • Added validation to ensure upload responses contain the expected hash format.

The orderbook API returns the appDataHash for both 200 and 201 on
PUT /api/v1/app_data/{app_data_hash}, per the OpenAPI spec this package
pins its own codegen to. We were typing it as AppDataObject.

Our own test already asserted the correct runtime shape - it mocks a
bare string and expects the result to equal the hash - so the type was
the only thing that was wrong.

Also pins the return type in the test so a regression fails tsc rather
than surviving until someone hits it at runtime.
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9578722d-151c-444e-a303-66b067a90bc9

📥 Commits

Reviewing files that changed from the base of the PR and between 8a756e8 and 09987cd.

📒 Files selected for processing (2)
  • packages/order-book/src/api.spec.ts
  • packages/order-book/src/api.ts

📝 Walkthrough

Walkthrough

uploadAppData now returns an AppDataHash. The AppData upload test verifies the returned value as an AppDataHash string. The PUT request behavior remains unchanged.

Changes

AppData upload return type

Layer / File(s) Summary
Update uploadAppData contract and validation
packages/order-book/src/api.ts, packages/order-book/src/api.spec.ts
uploadAppData now declares and documents a Promise<AppDataHash> return value. The test adds a typed assignment and string assertion for the returned hash.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 09987

The public method now accurately returns the hash string produced by the order book, with documentation and tests updated accordingly. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: shoom3301

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the corrected return type for uploadAppData.
Linked Issues check ✅ Passed The changes satisfy issue #193 by annotating uploadAppData to return the appDataHash as AppDataHash.
Out of Scope Changes check ✅ Passed The changes are limited to the return type, documentation, and test assertion for uploadAppData.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/order-book/src/api.spec.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

packages/app-data/tsconfig.json(2,14): error TS6053: File '@cow-sdk/typescript-config/base.json' not found.

packages/order-book/src/api.ts

Parsing error: Unable to parse the specified 'tsconfig' file. Ensure it's correct and has valid syntax.

packages/app-data/tsconfig.json(2,14): error TS6053: File '@cow-sdk/typescript-config/base.json' not found.


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.

@gomesalexandre

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 16, 2026
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.

bug: returns appDataHash

1 participant