fix: surface Pydantic array validation errors from SCALE 25.04+ API
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 <noreply@anthropic.com>
This commit is contained in:
parent
2979d54279
commit
7a66e59dc7
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue