Skip to content

Fix 5 bugs in templates, config, and hand-written files#75

Open
luke-hagar-sp wants to merge 1 commit intomainfrom
fix/cross-sdk-bug-fixes
Open

Fix 5 bugs in templates, config, and hand-written files#75
luke-hagar-sp wants to merge 1 commit intomainfrom
fix/cross-sdk-bug-fixes

Conversation

@luke-hagar-sp
Copy link
Contributor

@luke-hagar-sp luke-hagar-sp commented Mar 5, 2026

Summary

Cross-SDK audit identified 5 bugs in the TypeScript SDK across mustache templates, build config, and hand-written files. Template fixes will propagate to generated code on next make build.

Bug Fixes

Critical

T1: undefined + "/v3" produces "undefined/v3" — fallback basePath never triggers

  • sdk-resources/resources/baseApi.mustache L45: When configuration.basePath is undefined, the expression configuration.basePath + "/v3" evaluates to "undefined/v3" (a truthy string), so the || this.basePath fallback never activates.
  • Fix: Added explicit null check: (configuration.basePath != null ? (configuration.basePath + "/{apiVersion}") : undefined) || this.basePath.

T2: Null dereference on optional configuration parameter

  • sdk-resources/resources/common.mustache L140: axiosRetry(axios, configuration.retriesConfig) — no null check, but the configuration parameter is optional (configuration?: Configuration). When called without a configuration, this throws a null reference error.
  • Fix: Wrapped in if (configuration?.retriesConfig) { axiosRetry(axios, configuration.retriesConfig); }.

T3: Same operator precedence bug as T1 in request URL construction

Medium

T4: Generic package version 1.6.7 out of sync with other packages at 1.7.22

  • sdk-resources/generic-config.yaml L8: npmVersion: 1.6.7 while all other packages (v3, beta, v2024, v2025, v2026) are at 1.7.22.
  • Fix: Updated to 1.7.22.
  • Makefile: Generic package was missing from the build: target.
  • Fix: Added the generic build step.

Low

T5: throw new Error(error) destroys original stack trace

  • sdk-output/configuration.ts L253: Wrapping the caught error in new Error(error) loses the original stack trace and coerces the error to a string.
  • Fix: Changed to throw error to preserve the original error object and stack.

Verification

  • Template fixes (T1-T3) verified by source inspection; will take effect on next make build
  • T4 verified by comparing npmVersion across all *-config.yaml files
  • T5: npx tsc --noEmit shows only pre-existing esModuleInterop errors unrelated to our changes

Test plan

  • Run make build && npm run build to verify generated code compiles with template fixes
  • Test SDK initialization without explicit basePath to confirm fallback works correctly
  • Verify generic package builds and has correct version after make build

🤖 Generated with Claude Code

- Fix undefined + "/v3" producing "undefined/v3" instead of triggering fallback in baseApi
- Add null check for configuration.retriesConfig before calling axiosRetry
- Fix same operator precedence bug in request URL construction in common
- Sync generic package version from 1.6.7 to 1.7.16 and add to Makefile build target
- Preserve stack trace by throwing error directly instead of wrapping in new Error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@luke-hagar-sp luke-hagar-sp force-pushed the fix/cross-sdk-bug-fixes branch from 5ea29ef to b1f36a8 Compare March 5, 2026 18:38
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