telemetry preference validation skips falsy non-boolean values and runs after telemetry init
- Dominant language
- TypeScript
- Stars
- 172
- Forks
- 207
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
### Summary
`validatePreferences()` only validates `preference.telemetry` inside a truthiness check, so falsy non-boolean values such as `0` are accepted without throwing. Separately, `createBaseAccountSDK()` initializes telemetry before it calls `validatePreferences()`, so invalid telemetry preferences can be acted on before validation runs.
### Why this matters
The documented opt-out value is `preference: { telemetry: false }`. If a caller accidentally passes a falsy non-boolean value such as `0`, the SDK currently does not reject it during preference validation. Since the runtime check uses strict comparison (`telemetry !== false`), `0` is treated as not opted out and telemetry remains enabled.
### Code paths
`packages/account-sdk/src/util/validatePreferences.ts`:
```ts
if (preference.telemetry) {
if (typeof preference.telemetry !== 'boolean') {
throw new Error(`Telemetry must be a boolean`);
}
}
```
`packages/account-sdk/src/interface/builder/core/createBaseAccountSDK.ts` initializes telemetry before validating preferences.
### Expected behavior
Preference validation should reject any defined non-boolean `telemetry` value, including falsy values like `0`, before telemetry initialization logic can use it.
Contributor guide
Research direction
Read packages/account-sdk/src/util/validatePreferences.ts and packages/account-sdk/src/interface/builder/core/createBaseAccountSDK.ts first. Trace preference validation and telemetry initialization in that entry point; done means every defined non-boolean telemetry value, including 0, is rejected before telemetry initialization can use it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100