Skip to content

Code examples that run as copied, and page statements matched to the SDKs - #99

Merged
DrAlexHarrison merged 3 commits into
mainfrom
muse/docs-fixes
Nov 22, 2026
Merged

DrAlexHarrison merged 3 commits into
mainfrom
muse/docs-fixes

Conversation

@DrAlexHarrison

@DrAlexHarrison DrAlexHarrison commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Fixes for code examples a partner would copy and break on, and for page statements both SDKs and their fixtures contradict. Muse (Meta Muse Code, Meta training off) wrote it in a code lane. A Claude read the whole diff, checked each fix against saturday-node and saturday-python source and fixtures, fixed two of Muse's changes, and reran test-response-examples.py, check-engine-constants.py and check-app-claims.py (all pass). The drift check needs fuel-backend and was not run here. No landing label: this repo's content owner decides.

Examples fixed

  • OAuth: the TypeScript refresh now saves the rotated refresh token. Before, copied code logged the athlete out after the 10-minute grace window. The token exchange checks status first.
  • Retries: a 429 with no Retry-After no longer raises KeyError (Python) or retries at once (TypeScript). A daily ceiling with no header still schedules after midnight UTC.
  • Webhooks: signature parsing returns 400 on a malformed header instead of a 500. The timingSafeEqual call checks lengths first. The re-enable curl sends Content-Type: application/json.
  • Create calls for athletes, webhooks and the OAuth token check the status before reading success fields. Batch calculate raises on a whole-request error, and bulk create prints per-item errors.
  • The activity create examples send is_race_event and meal_before_min, which the page says exact numbers need.
  • The freemium display snippet reads numbers from prescription on an activity calculation.
  • The attribution example links to https://saturday.fit in place of an invented /subscribe?ref= link.
  • Every requests call passes timeout=30. Bare routes in bash blocks became curl. The Quickstart says the TypeScript snippets need an ES module.
  • Trimmed response examples gained the fields the types require (attribution, safety, totals, stored athlete fields).

Page statements corrected (both SDKs and fixtures disagree with the page)

  • precision is read when present; contract samples omit it on some answers.
  • plan_basis.source adds trial_allowance and simulation_allowance (both SDKs).
  • The Quickstart's production example drops onboarding.url (sandbox only).
  • documentation_url examples use the catalog's guide URLs. Error Handling names the catalog's not_found code.
  • The OAuth page says how to pass an access token to either SDK.

Kept as they were after review against fuel-backend's code (lead CORE-CALC, 2026-11-22)

  • Single athlete create has no required field (pkg/api/athletes.go); only a batch item needs one of name, email or external_id (pkg/api/batch.go). The page now says both. The SDK comments that call an identifier required on single create are the side to correct.
  • The export includes conversations when the athlete has any (pkg/api/gdpr.go; the key is omitted when empty, which is why the SDK fixture lacks it). Both pages name them again.
  • Checked and right as changed: the 503 key-verification code is service_unavailable (pkg/gateway/middleware.go); onboarding.url is sandbox only (hostedOnboardingLinked); plan_basis.source has trial_allowance and simulation_allowance; precision is optional on the wire.

For your call

  • Authentication table: the 503 key-verification row now says service_unavailable (the catalog pairs internal_error with 500). The other fix would be keeping internal_error and saying 500.
  • Left alone on purpose: the 1, 3, 5, 7 or 9 scale wording (PR Satiety and fitness take 1, 3, 5, 7 or 9; Max Carbs steps of 10 #98). The live settings schema says integer 1 to 9, and a live export stores sweat_level: 6, so the page and the schema still differ.

SDK or fixture side, untouched (for the SDK owners)

  • Contract samples use milliseconds for trial_ends_at, fueling updated_at and webhook created_at. Live captures and the docs use seconds.
  • Contract samples have attribution.required: false in all 13 objects; live has true in 11 of 11.
  • The error catalog sample lacks product_not_found and missing_identifier, and marks the daily 429 codes retryable: true.
  • organizations.list() takes no limit or cursor in either SDK. batchCalculate cannot send estimate_only or return headers.
  • The Python SDK defaults activities.list to limit=20; the docs say 50.
  • Node rethrows raw connection failures where Python wraps them. Coach registerWebhook sends no events in Node and [] in Python.

Unsettled, no change

  • License add and remove response shapes, seat PATCH start_date, infer brick segments, the coach webhook event id, coach event names in the TypeScript types, server acceptance of estimate_only, onboarding age bounds, products and nutrition gating on product routes, and ignored-versus-refused server-owned PATCH fields. No fixture settles any of these.
  • POST /v1/nutrition/extract ships in both SDKs and has no page.

🤖 Generated with Claude Code

DrAlexHarrison and others added 3 commits November 22, 2026 10:40
Guard optional precision and Retry-After, add status checks and batch error handling, store rotated OAuth tokens, correct error catalog details, and align response examples with the SDK types and fixtures.
…etry-After

The settings-scale wording goes back to "1, 3, 5, 7 or 9": PR #98 sets those values on purpose.
A daily ceiling with no Retry-After header (older API) still schedules after midnight UTC, as
saturday-node's RateLimitError treats it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Single athlete create takes no required field (pkg/api/athletes.go); only a batch item
  needs one of name, email or external_id (pkg/api/batch.go, missing_identifier).
- The export carries conversations when the athlete has any (pkg/api/gdpr.go,
  gdpr_types.go: conversations, omitted when empty), so both pages name them again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@DrAlexHarrison
DrAlexHarrison merged commit b59450a into main Nov 22, 2026
4 checks passed
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