From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A76861FF140 for ; Fri, 10 Apr 2026 17:10:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 372F3215A2; Fri, 10 Apr 2026 17:10:32 +0200 (CEST) From: Shan Shaji To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox_dart_api_client 2/2] deps: add objective_c dependency to access NSError's code property Date: Fri, 10 Apr 2026 17:09:35 +0200 Message-ID: <20260410150935.25870-8-s.shaji@proxmox.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260410150935.25870-1-s.shaji@proxmox.com> References: <20260410150935.25870-1-s.shaji@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775833723657 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.154 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: AGR3P3CLRC3VDZSEMDZ6II32DTK7WETV X-Message-ID-Hash: AGR3P3CLRC3VDZSEMDZ6II32DTK7WETV X-MailFrom: s.shaji@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Starting from `v9.0.0` of the `objective_c` package, `NSError` is defined as an extension type [0] instead of a wrapper class in Dart. As a result, the `code` property is not accessible at compile time unless the extension type is explicitly imported, even though the underlying object exposes it at runtime. To fix this, the `objective_c` dependency has been added and imported the dependency were the code property is accessed. - [0] https://github.com/dart-lang/native/pull/2723 Signed-off-by: Shan Shaji --- lib/src/authenticate.dart | 15 ++++++--------- pubspec.lock | 2 +- pubspec.yaml | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/src/authenticate.dart b/lib/src/authenticate.dart index 4c9ae22..203c165 100644 --- a/lib/src/authenticate.dart +++ b/lib/src/authenticate.dart @@ -7,6 +7,7 @@ import 'package:http/http.dart' as http; import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart'; import 'package:proxmox_dart_api_client/src/handle_ticket_response.dart'; import 'package:proxmox_dart_api_client/src/models/serializers.dart'; +import 'package:objective_c/objective_c.dart'; /// Returns an authenticated client to work with if successful. /// @@ -38,10 +39,7 @@ Future authenticate( print("retrying for backward compat!"); final errors = jsonDecode(response.body)['errors'] ?? {}; if (errors.containsKey('new-format')) { - var body = { - 'username': username, - 'password': password, - }; + var body = {'username': username, 'password': password}; response = await httpClient .post(credentials.ticketUrl, body: body) .timeout(Duration(seconds: 25)); @@ -50,13 +48,12 @@ Future authenticate( credentials = handleAccessTicketResponse(response, credentials); - return ProxmoxApiClient( - credentials, - httpClient: httpClient, - ); + return ProxmoxApiClient(credentials, httpClient: httpClient); } on TimeoutException catch (_) { throw ProxmoxApiException( - 'Authentication takes unusually long, check network connection', 408); + 'Authentication takes unusually long, check network connection', + 408, + ); } on NSErrorClientException catch (e) { // Treat untrusted server certificate (-1202) as a handshake failure. if (e.error.code == -1202) { diff --git a/pubspec.lock b/pubspec.lock index 66aa9b8..ffdf790 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -375,7 +375,7 @@ packages: source: hosted version: "2.0.2" objective_c: - dependency: transitive + dependency: "direct main" description: name: objective_c sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" diff --git a/pubspec.yaml b/pubspec.yaml index 9094c4d..a3426cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: retry: ^3.1.0 cronet_http: ^1.5.0 cupertino_http: ^2.3.0 + objective_c: ^9.3.0 dev_dependencies: lints: ^6.0.0 -- 2.50.1