Skip to content

fix(sublime): apply default base URL and use server-side time filter#301

Open
maximelb wants to merge 2 commits into
masterfrom
fix/sublime-adapter-baseurl-and-volume
Open

fix(sublime): apply default base URL and use server-side time filter#301
maximelb wants to merge 2 commits into
masterfrom
fix/sublime-adapter-baseurl-and-volume

Conversation

@maximelb

@maximelb maximelb commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The Sublime Security audit-log adapter had two bugs that made it unusable in production. Both were reproduced from a user report and verified against Sublime's official API docs.

1. unsupported protocol scheme "" when no base URL is set

The North America default base URL (https://platform.sublime.security) was only applied in SublimeConfig.Validate(), but the general adapter runner constructs the adapter directly and never calls Validate(). The constructor already backfilled the poll interval for exactly this reason — it just forgot the base URL. So an unset base_url produced a schemeless request URL and every poll failed.

Fix: backfill defaultBaseURL in the constructor next to the poll-interval default.

2. context deadline exceeded on high-volume tenants

Every poll re-paginated the entire audit log from offset=0 (offset 0, 500, 1000, … — hundreds of pages), pulling every page and discarding old events client-side. On a tenant with a large backlog, a single request eventually exceeded the 30s HTTP timeout. The adapter never used the API's time filter.

Fix: send the documented created_at[gte] filter (inclusive, ISO 8601 UTC) so each poll only fetches the recent window. The overlap is still re-fetched and the dedupe map suppresses re-shipping, so shipping semantics are unchanged — the fetched set just shrinks from the whole history to the recent window.

Minor

  • Return an explicit error on a non-200 response (previously it returned the nil error from the preceding successful Do() call).
  • Cap pagination depth per poll as a backstop against a misbehaving API.

Tests

  • Mock API now honours created_at[gte].
  • New regression TestBaseURLDefaultBackfilled: constructing with an empty base URL yields the default.
  • New regression TestMockHighVolumeUsesTimeFilter: a 100k-event pre-start backlog must not be walked by offset — the adapter stays at offset=0 and sends the time filter.
  • Updated TestMakeOneRequestNon200 to expect the explicit error.

All ./sublime/ tests pass; go vet and the containers/general build are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NThfoB4tBLPk7SqABt7GPR

Two bugs made the Sublime audit-log adapter unusable in production:

1. `unsupported protocol scheme ""` when no base URL was configured. The
   North America default was only applied in Validate(), which the general
   adapter runner never calls -- it constructs the adapter directly. The
   constructor already backfilled the poll interval for this reason but not
   the base URL, so an unset base_url produced a schemeless request URL.
   Backfill defaultBaseURL in the constructor alongside the poll interval.

2. `context deadline exceeded` on busy tenants. Every poll re-paginated the
   entire audit log from offset 0 (offset 0, 500, 1000, ... hundreds of
   pages), discarding old events client-side. On a tenant with a large
   backlog a single request eventually exceeded the HTTP timeout. Use the
   API's created_at[gte] filter (documented, inclusive, ISO 8601 UTC) to
   fetch only the recent window; the overlap is still re-fetched and the
   dedupe map suppresses re-shipping, so shipping semantics are unchanged.

Also: return an explicit error on a non-200 (previously the returned error
was the nil from the preceding successful Do call), and cap pagination depth
per poll as a backstop against a misbehaving API.

Tests: mock now honours created_at[gte]; added regressions for the base URL
backfill and for the high-volume path (a 100k-event pre-start backlog must
not be walked by offset).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NThfoB4tBLPk7SqABt7GPR
lcbill
lcbill previously approved these changes Jul 2, 2026
A base URL copied from the dashboard with a trailing slash produced a
`//v0/...` request path. Trim trailing slashes when normalizing the config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NThfoB4tBLPk7SqABt7GPR
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.

2 participants