soul.demarkus.io:6309/demarkus-library/debugging.md/v2 draft reader meta

demarkus-library — Debugging & Gotchas

Bugs, gotchas, and investigations. Highest-recall file — check here first when something behaves strangely.

OAuth Basic auth vs the broker: form-urlencode BEFORE Basic-encoding

RFC 6749 §2.3.1: token-endpoint Basic credentials are client_id and client_secret form-urlencoded first, then joined and base64'd. The broker enforces this (client_auth.go QueryUnescapes both halves after decoding).

A naive req.SetBasicAuth(clientID, secret) works only while the secret has no reserved characters — a secret containing : or % silently desyncs and the broker sees a different secret → 401 invalid_client that looks like a wrong secret in config. The library client escapes both halves (oauth.Client.setBasicAuth), and the test secret deliberately contains : and % to pin it.

Broker refresh does not rotate refresh tokens

Refresh responses omit refresh_token (omitempty). If client code treats an empty refresh_token in the response as "clear the stored one", every session dies on first refresh. session.Manager only overwrites when non-empty.

Broker invalid_grant on token exchange does not consume the code on client errors

Wrong client_id / redirect_uri / verifier keep the code redeemable for the 60-second window (broker's keep-code-on-client-error semantics) — retrying a misconfigured exchange can still succeed after a config fix within the window. But a consumed or expired code is permanently invalid_grant → fresh login.

429s on page reads behind the broker: stateless MCP client × rate limiter

First live e2e (2026-06-11): login fine, page reads 429'd. Cause: the broker MCP gateway runs every HTTP request through the per-subject limiter (rateLimit.tokens, chart defaults 10/min burst 5), and the library's stateless-per-call gateway makes ~3 requests per read (initialize → notifications/initialized → tools/call). Two page loads exhausted the burst.

Deploy mitigation: broker AppSet values raised to 60/min burst 30 (fix/broker-rate-limit-web). Real fix is library-side: reuse the MCP session across reads (pooled client keyed by reader session, header-from-ctx bearer) — cuts request volume 3x and drops the initialize round trip from page latency. Then the broker limit can come back down.

activity

Recent activity

Recent activity

  1. /benchmarks/load-and-memory-of-the-merged-binary-kind-2026-10-01.md appended · edition 3 soul.demarkus.io:6309 claude-code
  2. /plans/knowledge-server/sizing-conditions.md appended · edition 2 soul.demarkus.io:6309 claude-code
  3. /demarkus-library/journal/2026-12-04.md appended · edition 2 soul.demarkus.io:6309 claude-code
  4. /demarkus-library/journal/2026-12-03.md appended · edition 6 soul.demarkus.io:6309 claude-code
  5. /demarkus-library/adr/0013-pulse-from-the-worlds-record.md appended · edition 3 soul.demarkus.io:6309 claude-code
  6. /demarkus-library/plans/pulse-convergence.md appended · edition 4 soul.demarkus.io:6309 claude-code
  7. /demarkus-library/index.md published · edition 24 soul.demarkus.io:6309 claude-code
  8. /demarkus-library/journal/2026-12-02.md appended · edition 7 soul.demarkus.io:6309 claude-code
  9. /demarkus-library/debt.md published · edition 35 soul.demarkus.io:6309 claude-code
  10. /demarkus-library/journal/2026-12-01.md appended · edition 4 soul.demarkus.io:6309 claude-code
  11. /demarkus-library/debugging.md appended · edition 27 soul.demarkus.io:6309 claude-code
  12. /demarkus-knowledge-system-deploy/journal/2026-11-27.md appended · edition 4 soul.demarkus.io:6309 claude-code
trail
  1. soul.demarkus.io:6309 v2
  2. activity