Skip to content

refactor: add internal/api operation layer shared by language bindings - #545

Merged
zeroshade merged 6 commits into
fix/install-verify-signaturesfrom
refactor/internal-api
Nov 4, 2026
Merged

zeroshade merged 6 commits into
fix/install-verify-signaturesfrom
refactor/internal-api

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Adds internal/api: search / resolve / install / uninstall / list implemented once over dbc.Client, for the WASM and C bindings that follow. Install/uninstall/list take an explicit directory or the user/system config level. NewClient returns an error for a malformed baseURL instead of panicking.

Also sets toolchain go1.27.3 in go.mod for CI and releases (the go minimum is unchanged).

Stacked on #544.

@amoeba amoeba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks reasonable.

Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
Comment thread internal/api/client.go Resolved
zeroshade added a commit that referenced this pull request Nov 4, 2026
Address review on #545: url.Parse alone accepts scheme- and host-less
strings. Extract validateRegistryEntry's checks into internal/registryurl
and use it for baseURL and credential URLs. Drop the inaccurate panic
comment and document why credentials match by host.
zeroshade added a commit that referenced this pull request Nov 4, 2026
…ries

Brings in internal/registryurl from #545; explicit registries, baseURL, and
injected credential URLs now all validate through registryurl.Parse, replacing
the local parseRegistryURL/absoluteURL helpers.
@zeroshade
zeroshade force-pushed the refactor/internal-api branch from dc2f0eb to 9586a44 Compare November 4, 2026 15:23
Changes:
- `Resolve` now sets `latest` to the newest stable version that has a package for the requested platform. Before, it used `GetPackage(nil, ...)`, which left `latest` empty whenever the newest stable version globally had no package for that platform.
- `Search` now fetches the unfiltered driver list and filters it itself, using the same path/title substring match as `Client.Search`. If some registries answer but nothing matches, it returns an empty `drivers` list with a `warning`. It only returns an error when no registry returned anything.
- Added tests for a partial registry outage with no matches, and for picking `latest` when the newest stable version doesn't support the requested platform.
Changes:
- `api.Search` and `api.Resolve` now decide that every registry failed by comparing the number of per-registry errors with the number of configured registries. They no longer use `len(drivers) == 0` as a stand-in. So when one registry has a valid empty index and another is down, you get an empty result with a `Warning` instead of an error.
- `dbc.Client.Search` now builds its error with a single `errors.Join` at the end. Before, it joined one error at a time, which nested them. Now each failed registry adds exactly one entry, so the count above is reliable.
- `api.Search` goes back to calling `c.Search(ctx, pattern)` directly, which removes the copy of the filtering logic.
- Added `TestSearchPartialFailureEmptyIndex`, which pairs a registry with an empty index and one that's down. Build, `go vet` and the full `go test ./...` suite pass.
Address review on #545: url.Parse alone accepts scheme- and host-less
strings. Extract validateRegistryEntry's checks into internal/registryurl
and use it for baseURL and credential URLs. Drop the inaccurate panic
comment and document why credentials match by host.
@amoeba

amoeba commented Nov 4, 2026

Copy link
Copy Markdown
Member

I had Opus 5.5 do a review across my manual reviews and it caught that there's no test for disabling signature verification here. Can we check?

@zeroshade

Copy link
Copy Markdown
Member Author

Good catch, there wasn't one at this layer (the CLI's TestInstallDriverNoSignature covers --no-verify's default side, but internal/api is what the bindings call). Added TestInstallAllowUnsigned in 8ce0374: an unsigned driver (test-driver-no-sig) is refused with the zero InstallOptions and leaves nothing installed, and installs with AllowUnsigned: true. I checked it fails if Install stops forwarding AllowUnsigned.

@zeroshade
zeroshade merged commit 014524f into main Nov 4, 2026
15 checks passed
@zeroshade
zeroshade deleted the refactor/internal-api branch November 4, 2026 20:11
zeroshade added a commit that referenced this pull request Nov 4, 2026
The WASM bindings drop their local DTOs and call `internal/api`, so they
share one implementation with the C API. npm `install(name, location, {
allowUnsigned })` exposes the signature opt-out.

Stacked on #545.

This branch was previously deployed

1 inactive deployment
snapshot — 8ce0374a Deployed Nov 4, 2026 by zeroshade via snapshot #1195
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