refactor(runtime): isolate HTTPRuntime target - #1121
Conversation
…e deleted SSE parser after the package-scoping edit The manual public->package access-control pass left HTTPRuntime non-compiling: checkStatus still referenced HTTPResponse's now-removed bare status/isSuccess (now only on .head), MultipartFormData's new builder API members defaulted to internal instead of package, and ServerSentEvents.swift was deleted outright rather than rescoped, breaking SSE stream parsing entirely.
Follow-up to the HTTPRuntime target isolation: registers the test target in the shared Xcode scheme, adds its spell-check terms, and updates Package.resolved to drop dependencies no longer pulled in by this trimmed-down package graph.
…ase, add addHeader - HTTPTransport.send/stream now throw typed HTTPError instead of any Error; URLSessionTransport already only ever threw HTTPError.transport, so this just tightens the contract. Dropped the redundant `throws` on the private makeURLRequest helper, which never actually threw. - Removed HTTPBody.multipart: callers now build the multipart body themselves via MultipartFormData.buildToTempFile(), set Content-Type, and pass .file. Keeps HTTPTransport from needing to know about multipart assembly. - Added HTTPRequestBuilder.addHeader(_:value:), which merges into an existing header (joined with "; ") instead of replacing it, for repeated directives like Prefer. Both setHeader and addHeader resolve the target key case-insensitively so differently-cased calls merge into one header instead of creating duplicates.
Supabase's own clients don't need it; downstream consumers can parse the raw streamed chunks themselves if they want SSE framing.
…sed doc references - checkStatus now requires a catch-all APIError type instead of falling back to a bare unexpectedStatus(status:body:) case, and reports decode failures as unexpectedResponse(response:underlyingError:) with the full response attached. - Commented out the still-unused HTTPError.encoding case. - Dropped doc comments referencing the (now removed) OpenAPI codegen tool.
…uild - TransferProgress/ProgressHandler were left `public` when the rest of HTTPRuntime was scoped down to `package`; the capability-matrix CI check flagged them as new, unregistered public API. Scope them to `package` like everything else in this target. - FoundationNetworking (swift-corelibs-foundation on Linux) has no async byte-streaming API (`bytes(for:)`/`AsyncBytes`), so URLSessionTransport.stream() failed to compile on Linux. Branch on `canImport(FoundationNetworking)`: Linux buffers the full response via `data(for:)` and yields it as a single chunk instead of streaming incrementally; Apple platforms keep the existing incremental byte-stream implementation.
…RuntimeTestHelpers
…e and dictionary Adds HTTPRuntimeTestHelpersTests to the shared Xcode scheme in alphabetical order between HelpersTests and HTTPRuntimeTests. Includes dictionary.txt entries for Xcode-related terms and formatting fixes to HTTPRuntimeTestHelpers source files.
…rget-085a05 # Conflicts: # Package.resolved # Package.swift
…r directives
addHeader joined repeated directives with "; ", conflicting with this repo's
Prefer convention (HTTPFields.appendOrUpdate, PostgrestQueryBuilder/
PostgrestTransformBuilder all use ","), which would make two addHeader("Prefer", ...)
calls read as one directive-with-parameter instead of two. Also replace an
existing directive sharing the same key prefix instead of duplicating it,
mirroring appendOrUpdate.
Addresses review feedback from spydon on #1121.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds the Sequence Diagram(s)sequenceDiagram
participant HTTPRequestBuilder
participant URLSessionTransport
participant URLSession
participant HTTPResponse
HTTPRequestBuilder->>URLSessionTransport: build HTTPRequest
URLSessionTransport->>URLSession: send URLRequest
URLSession-->>URLSessionTransport: return response data and headers
URLSessionTransport->>HTTPResponse: construct HTTPResponse
HTTPResponse->>HTTPResponse: validate status and decode APIError
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
docs/superpowers/ was already gitignored (deduped a redundant earlier entry too) but these two files were tracked before the rule existed.
|
The following capabilities are marked
These may have been renamed, removed, or never registered. Please update the capability matrix. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/HTTPRuntime/HTTPError.swift`:
- Around line 11-18: Update the associated error values in HTTPError cases
transport, decoding, and unexpectedResponse.underlyingError to use
Sendable-constrained error existentials, preserving their existing case names
and optionality while ensuring HTTPError satisfies strict-concurrency Sendable
requirements.
In `@Sources/HTTPRuntime/MultipartFormData.swift`:
- Around line 100-118: Update buildToTempFile() to explicitly set owner-only
POSIX permissions on tempFile immediately after FileManager.default.createFile
succeeds and before opening or uploading it, rather than relying on the process
umask. Preserve the existing cleanup and error-handling behavior, propagating or
mapping any permission-setting failure consistently with the method’s throws
contract.
In `@Sources/HTTPRuntime/URLSessionTransport.swift`:
- Around line 67-80: Update stream(_:) and its related streaming request path to
explicitly handle HTTPBody.file instead of allowing makeURLRequest to send an
empty body. Support file-backed uploads through the streaming implementation, or
validate and reject file bodies with an HTTPError before session.data(for:)
transmits the request; preserve existing behavior for non-file bodies.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2f39776d-4ce5-4d6a-958f-e4671e492c7d
⛔ Files ignored due to path filters (1)
Package.resolvedis excluded by!**/Package.resolved
📒 Files selected for processing (26)
.gitignorePackage.swiftSources/HTTPRuntime/HTTPError.swiftSources/HTTPRuntime/HTTPMethod.swiftSources/HTTPRuntime/HTTPRequest.swiftSources/HTTPRuntime/HTTPResponse.swiftSources/HTTPRuntime/HTTPTransport.swiftSources/HTTPRuntime/JSONCoding.swiftSources/HTTPRuntime/JSONValue.swiftSources/HTTPRuntime/MultipartFormData.swiftSources/HTTPRuntime/PathEncoding.swiftSources/HTTPRuntime/TransferProgress.swiftSources/HTTPRuntime/URLSessionTransport.swiftSources/HTTPRuntimeTestHelpers/AssertHTTPRequests.swiftSources/HTTPRuntimeTestHelpers/CurlCommand.swiftSources/HTTPRuntimeTestHelpers/HTTPStub.swiftSources/HTTPRuntimeTestHelpers/HTTPStubBody.swiftSources/HTTPRuntimeTestHelpers/HTTPTransportStub.swiftSupabase.xcworkspace/xcshareddata/xcschemes/Supabase.xcschemeTests/HTTPRuntimeTestHelpersTests/AssertHTTPRequestsTests.swiftTests/HTTPRuntimeTestHelpersTests/CurlCommandTests.swiftTests/HTTPRuntimeTestHelpersTests/HTTPStubTests.swiftTests/HTTPRuntimeTestHelpersTests/HTTPStubTraitTests.swiftTests/HTTPRuntimeTestHelpersTests/HTTPTransportStubTests.swiftTests/HTTPRuntimeTests/HTTPRuntimeTests.swiftdictionary.txt
💤 Files with no reviewable changes (1)
- .gitignore
Coverage Report for CI Build 30343991994Coverage increased (+0.2%) to 84.036%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Adds storage.vectors.{createBucket,getBucket,listBuckets,deleteBucket}
for Supabase Storage's alpha "vector buckets" feature, mirroring
supabase-js's supabase.storage.vectors client. Indexes and vector data
operations (put/get/query/delete vectors) are out of scope for this
pass.
The vector bucket paths/schemas are merged into openapi/storage.json
from the real docs:export output of supabase/storage's
claude/reverent-ramanujan-32755f branch (supabase/storage#1215), which
adds response schemas for these 4 endpoints (previously only errors
were documented). Sources/Storage/Generated is regenerated from that
spec via tools/openapi-codegen.
Since the generated StorageBackendAPI.Client and its models are
module-internal by convention, a new StorageVectorsClient wraps it with
a public API: VectorBucket/ListVectorBucketsResponse replace the
internal generated schemas, and the internal ErrorSchema is translated
to the existing public StorageError. StorageSessionTransport bridges
StorageClientConfiguration's StorageHTTPSession onto HTTPRuntime's
HTTPTransport, so the generated client goes through the same session
(auth headers, test stubbing) as the rest of Storage.
The whole surface is gated behind @_spi(Experimental), matching the
precedent set by Auth's WebAuthn support, since this is an alpha
feature that may change in a breaking way before general availability.
Built on #1121/#1099 (the isolated HTTPRuntime target and
openapi-codegen tool) rather than main.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…ping them makeURLRequest only copies .data bodies into httpBody; .file bodies were silently discarded, sending an empty body instead of the file's contents.
swift-format wraps the multi-line guard condition differently than the version used locally; add "posix" to the dictionary for .posixPermissions.
Summary
Isolates the zero-dependency
HTTPRuntimetarget out of #1099 into its own branch (no OpenAPI codegen tool, no generated Storage client), plus a newHTTPRuntimeTestHelperstarget for stubbingHTTPRuntimerequests under Swift Testing.Test plan
swift buildswift test --filter HTTPRuntimeTests(10 tests)swift test --filter HTTPRuntimeTestHelpersTests(18 tests)./scripts/spell-check.sh./scripts/format.sh(no changes)swift:6.1image)