Skip to content

[pigeon] Crash in swift: Could not cast value of type 'NSNull' to 'NSArray' #129283

@dnys1

Description

@dnys1

Is there an existing issue for this?

Steps to reproduce

  1. Using pigeon 10.0.1
  2. Run swift generator for schema:
@FlutterApi()
abstract class NativeAuthPlugin {
  @async
  NativeAuthSession fetchAuthSession();
}

class NativeAuthSession {
  late bool isSignedIn;

  String? userSub;
  NativeUserPoolTokens? userPoolTokens;

  String? identityId;
  NativeAWSCredentials? awsCredentials;
}

class NativeUserPoolTokens {
  late String accessToken;
  late String refreshToken;
  late String idToken;
}

class NativeAWSCredentials {
  late String accessKeyId;
  late String secretAccessKey;
  String? sessionToken;
  String? expirationIso8601Utc;
}
  1. Send null for userPoolTokens (code from unit test)
    lazy var codec = NativeAuthPluginCodec.shared

    func send(
        onChannel channel: String,
        message: Data?,
        binaryReply callback: FlutterBinaryReply? = nil
    ) {
        let authSession = NativeAuthSession(
            isSignedIn: isSignedIn,
            userSub: nil,
            userPoolTokens: nil,
            identityId: nil,
            awsCredentials: nil
        )
        let encodedAuthSession = codec.encode(authSession)
        callback?(encodedAuthSession)
    }

Expected results

Passing null for userPoolTokens should work. This code worked with pigeon v9 output.

Actual results

A crash is observed running in Xcode.

Code sample

Included above.

Screenshots or Video

Screenshot 2023-06-21 at 8 08 47 AM

Logs

Logs
Test Case '-[unit_tests.NativeAuthPluginTests testFetchAuthSessionSignedIn]' started.
Could not cast value of type 'NSNull' (0x107eaa978) to 'NSArray' (0x107eaaa20).
2023-06-21 08:02:22.225474-0700 Runner[54059:310281] Could not cast value of type 'NSNull' (0x107eaa978) to 'NSArray' (0x107eaaa20).

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1)
[✓] VS Code (version 1.79.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: fatal crashCrashes that terminate the processc: regressionIt was better in the past than it is nowfound in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions