Skip to content

pkg/hubapi: add HTTP client and protocol types for syz-hub - #8214

Open
ramosian-glider wants to merge 1 commit into
google:masterfrom
ramosian-glider:hub-http-pr1-hubapi
Open

ramosian-glider wants to merge 1 commit into
google:masterfrom
ramosian-glider:hub-http-pr1-hubapi

Conversation

@ramosian-glider

@ramosian-glider ramosian-glider commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Add the standalone pkg/hubapi package providing the HTTP client and JSON wire protocol types for syz-hub. This PR is completely additive and independently mergeable.

Migration stack for #8176

  1. pkg/hubapi: add HTTP client and protocol types for syz-hub #8214 (this PR): add pkg/hubapi HTTP client and protocol types
  2. syz-hub, syz-manager, tools/syz-hubtool: migrate from pkg/rpctype to HTTP #8215 (draft): migrate syz-hub, syz-manager, tools/syz-hubtool, and docs/configs to HTTP
  3. pkg/rpctype: remove unused net/rpc hub package #8216 (draft): remove unused pkg/rpctype package

Summary

  • Defines PathConnect = "/api/connect", PathSync = "/api/sync", HeaderClient = "X-Syz-Client", HeaderManager = "X-Syz-Manager", and JSON wire types Input, ConnectReq, SyncReq, SyncResp.
  • Drops legacy dead fields from the wire protocol: SyncReq.Add/Del (no longer sent by syz-manager) and SyncResp.Progs (superseded by Inputs []Input).
  • Keeps Manager out of JSON (json:"-") and passes client/manager identity and bearer credentials in HTTP headers (Authorization: Bearer <token>, X-Syz-Client, X-Syz-Manager) so syz-hub can authenticate requests before reading or decompressing bodies.
  • NewClient(client, addr, key, opts...) validates http:// or https:// scheme, non-empty host, no URL userinfo, and no query/fragment; rejects unexpected redirects; defaults to ambient GCE OAuth bearer tokens via pkg/auth.MakeCache when key == "" (with WithHTTPClient applying to both API and metadata calls).
  • Sends gzipped JSON POST requests (Content-Type: application/json, Content-Encoding: gzip) and bounds decoded responses to 256 MiB (4 KiB for error bodies).

Part of #8176

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the pkg/hubapi package, which defines the data structures and an HTTP client for communicating with syz-hub, along with a corresponding test suite. The review feedback highlights a critical testing issue in pkg/hubapi/hubapi_test.go where require.NoError is used inside an HTTP handler goroutine (both directly and within the decodeGzipJSON helper). Because require calls t.FailNow(), which invokes runtime.Goexit(), using it in a non-test goroutine will silently terminate the handler rather than failing the test. It is recommended to use t.Error and return early instead.

Comment thread pkg/hubapi/hubapi_test.go Resolved
Comment thread pkg/hubapi/hubapi_test.go Resolved
@github-actions github-actions Bot added the well-shaped PR has no conflicts and all checks pass label Nov 26, 2026
@github-actions
github-actions Bot requested a review from a-nogikh November 26, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

well-shaped PR has no conflicts and all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant