Skip to content

Parity with serpapi-ruby: lastError, masked API key, archive tests, safer release - #1

Open
jvmvik wants to merge 3 commits into
masterfrom
parity-fixes
Open

jvmvik wants to merge 3 commits into
masterfrom
parity-fixes

Conversation

@jvmvik

@jvmvik jvmvik commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes the gaps a parity review against serpapi-ruby (the reference implementation) found. Bumps the version to 1.2.0.

Changes

  • Client.lastError() returns a serpapi.ErrorInfo with message, the HTTP status, the request url without the api_key, and search_id, mirroring serpapi-ruby's SerpApiError. Every request clears it, so it only describes the most recent call.
  • API key masking: printing a client with {f} masks the key (abcd****wxyz), like serpapi-ruby's inspect. The key moved out of Client.params, so a {any} dump of the client state no longer shows it as bytes.
  • Live tests for searchArchiveHtml, searchArchiveMd, searchArchiveAs and locationAs.
  • rake release runs lint test itest oobt first, and refuses unless it's on master with a clean git status --porcelain and SERPAPI_KEY set.
  • README documents engine(), apiKey(), serpapi.version, printing the client, and lastError().

Breaking changes (shipping in 1.2.0 by decision)

  • Client.last_error is now ?serpapi.ErrorInfo instead of ?[]u8.
  • api_key is no longer in Client.params.items; use apiKey().

Checks

  • zig build lint: pass
  • zig build test: 30/30
  • zig build itest (live, SERPAPI_KEY set): 17/17
  • zig build oobt: pass; it reports 1.2.0
  • zig build cov (with the key): ~98%
  • Two review rounds (agent reviewer): approved with nits; all nits fixed.

The README's pinned-dependency example stays at v1.1.0 until the v1.2.0 tag exists. #2 (image upload) is stacked on this branch.

🤖 Generated with Claude Code

jvmvik and others added 3 commits November 2, 2026 20:21
- F13: Client.lastError() returns a serpapi.ErrorInfo with the message,
  HTTP status, request URL without the api_key, and the search id of the
  failed search, mirroring serpapi-ruby's SerpApiError fields
- F13b: Client.format masks the API key the way serpapi-ruby's inspect
  does. The key now lives in its own field behind a many-item pointer, so
  `{any}` on the client or its params prints an address, not the key
- D3: live tests for searchArchiveAs, searchArchiveHtml, searchArchiveMd,
  locationAs, and lastError (401 on a bad key, 404 on an unknown archive)
- D5: rake release runs lint, test, itest and oobt first, behind a
  preflight that needs SERPAPI_KEY and an empty `git status --porcelain`
  (`git diff --quiet` missed staged and untracked files)
- D6: README documents engine(), apiKey(), serpapi.version, printing the
  client, and lastError()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- errorMessage() and lastError() describe the most recent request only:
  fetch clears the previous failure first, so a success or a transport
  error (DNS, connection, TLS) leaves them null instead of reporting an
  older 404. Offline test: 404, then success, then a refused connection
- rake release:preflight also requires HEAD to be master, since release
  pushes master and the tag
- CHANGELOG: the api_key leaving params and the new last_error type are
  Breaking changes; the per-request lastError is a Behavior change (D7)
- recordUrl uses `if (self.last_error) |*info|`; the Client doc comment
  names lastError() as per-instance state too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Breaking changes ship in this minor release by maintainer decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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