Repository navigation
client/uniffi: rename LzError message fields to reason; compile the bindings in CI - #15
Merged
Merged
Conversation
…s in CI `LzError::Lease` and `LzError::Registration` had a field named `message`. UniFFI makes each variant a Kotlin exception class, where that property clashes with `Throwable.message`, so the generated Kotlin didn't compile. Rename the field to `reason`. This changes the Swift and Kotlin API, which v0 allows (spec §7). Add `client/uniffi/check-bindings.sh` and a CI job that runs it: it generates the bindings, compiles the Kotlin against JNA (pinned compiler and JNA, checked by SHA-256), and typechecks the Swift against the generated header. The README also says what to do with the stray `liblz_client_uniffi-<hash>.so` that cargo-ndk copies into `jniLibs` for an app crate that depends on this one. Fixes #14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The lease test checks that `reason` carries the core's text, not only the variant. - check-bindings.sh fails in CI when `swiftc` is missing instead of skipping Swift, downloads over HTTPS only, and says the Swift is typechecked rather than compiled. - CONTRIBUTING.md lists the script for changes to what client/uniffi exports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14.
What
LzError::Lease { message }andLzError::Registration { message }become{ reason }. UniFFI makes each variant a Kotlin exception class, where amessageproperty clashes withThrowable.message, so the generated Kotlin didn't compile. The RustDisplaytext is unchanged ("invalid lease: …"). This changes the Swift and Kotlin API (e.reasoninstead ofe.message), which v0 allows (spec §7). Apps that patch the generated file at build time can drop that workaround once they move their pin.client/uniffi/check-bindings.shbuilds the crate, generates both bindings, compiles the Kotlin against JNA, and typechecks the Swift against the generated header and module map. The Kotlin compiler (2.4.21) and JNA (5.17.0) are downloaded over HTTPS, pinned, and checked against their published SHA-256 sums before anything runs. The newuniffi-bindingsjob runs it; in CI a missingswiftcfails the job rather than skipping Swift. CONTRIBUTING.md lists the script for changes to whatclient/uniffiexports.liblz_client_uniffi-<hash>.sothatcargo-ndkcopies intojniLibswhen an app crate depends on this one: nothing loads it, so delete it after the build. The crate keeps itscdylibtype, which apps that use it on its own still need.Tested
val `message`: kotlin.Stringat line 3956, matching the issue. After the rename it'sval `reason`.swiftc -typecheckon the generated Swift passes locally (macOS).uniffi-bindings: "Kotlin compiles", "Swift typechecks" on Ubuntu).tests/bindings.rsnow checks thatLzError::Lease { reason }carries the core's text.cargo fmt --check,cargo clippy -p lz-client-uniffi --all-targets -D warnings,cargo test -p lz-client-uniffi,scripts/privacy-guards.sh,typos,shellcheck. The full-workspace and 1.89 runs were left to CI. No dependencies changed.🤖 Generated with Claude Code