From 7a66e59dc76ae8723e2c1e4e2bc9aaec45bfc13b Mon Sep 17 00:00:00 2001 From: Kevin Adams Date: Tue, 26 May 2026 21:12:44 -0400 Subject: [PATCH] fix: surface Pydantic array validation errors from SCALE 25.04+ API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SCALE 25.04 returns validation errors as a JSON array rather than a {message: "..."} hash. The error detail was silently lost, making 4xx failures appear as bare status lines in logs. Now handles both formats. Prompted by a transient 422 on /iscsi/target during first-run testing on SCALE 25.04 — root cause was iSCSI service mid-reload, not a format incompatibility. Plugin is compatible with SCALE 25.04 as-is. Co-Authored-By: Claude Sonnet 4.6 --- perl5/PVE/Storage/Custom/TrueNAS.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/perl5/PVE/Storage/Custom/TrueNAS.pm b/perl5/PVE/Storage/Custom/TrueNAS.pm index d46d6d8..a948bf7 100644 --- a/perl5/PVE/Storage/Custom/TrueNAS.pm +++ b/perl5/PVE/Storage/Custom/TrueNAS.pm @@ -187,7 +187,13 @@ sub _api { my $detail = ''; eval { my $body = decode_json($res->content); - $detail = " — $body->{message}" if ref $body eq 'HASH' && $body->{message}; + if (ref $body eq 'HASH' && $body->{message}) { + $detail = " — $body->{message}"; + } elsif (ref $body eq 'ARRAY' && @$body) { + # SCALE 25.04+ returns Pydantic validation errors as an array + my @msgs = map { $_->{message} // $_->{msg} // '' } @$body; + $detail = " — " . join('; ', grep { length } @msgs); + } }; my $msg = "TrueNAS API $method $path: " . $res->status_line . $detail; _log('err', $msg);