Skip to content

Errors Produced in try_lift are difficult to Debug. #2563

Closed

Description

@oldwomanjosiah

Recently I was working on adding support for sending [Uuid] across the FFI boundary as a String. Originally, I had introduced this conversion using a bare

use uuid::Uuid;

uniffi::custom_type!(Uuid, String, { remote });

This appeared to work on Android and iOS when converting from ParcelUuid and CBUUID respectively, but would periodically crash with just "invalid length: expected length 32 for simple format, found 4" when running on iOS. This message is coming from the error returned from Uuid::try_from(String), which was being lifted for a field of type Vec<Uuid>, and was being passed a short UUID as specified by Bluetooth 4.

I understand that this isn't necessarily this libraries responsibility, but it would be really nice if (when the ffi-trace feature is enabled) more context would be attached to the anyhow report to aid in debugging.

I'm thinking:

  1. Unconditionally attach type names and source location information to custom_type!() invocations.
  2. When ffi-trace is enabled:
    • Attach type name in try_lift
    • Attach field name in try_read_field

Activity

  1. oldwomanjosiah commented on Jun 6, 2025

    @oldwomanjosiah
    ContributorAuthor

    I would also be interested in contributing to these changes, if they are something that the project would be interested in but aren't a high priority for anyone else atm.

  2. mhammond commented on Jun 7, 2025

    @mhammond
    Member

    hi, thanks for looking at uniffi! We'd be happy to look at zero (ish?) cost improvements to our diagnostics here.

  3. mhammond commented on Aug 4, 2025

    @mhammond
    Member

    Let's call this fixed by #2564, but we'd welcome more improvements or concrete problem cases in new PRs/issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions