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 B2AF91FF13C for ; Thu, 16 Apr 2026 08:20:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8908721C90; Thu, 16 Apr 2026 08:20:39 +0200 (CEST) Date: Thu, 16 Apr 2026 08:20:03 +0200 From: Arthur Bied-Charreton To: Lorne Guse Subject: Re: proxmox-truenas storage plugin api2 issue Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776320326377 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.776 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Message-ID-Hash: ZDASWZMIUHVYCOCKJWJXMLFR7ZGNOOE5 X-Message-ID-Hash: ZDASWZMIUHVYCOCKJWJXMLFR7ZGNOOE5 X-MailFrom: a.bied-charreton@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 CC: Proxmox VE development discussion X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Apr 16, 2026 at 08:03:25AM +0200, Arthur Bied-Charreton wrote: > On Wed, Apr 15, 2026 at 09:59:20PM +0000, Lorne Guse wrote: > > One of my users ran across an issue I could use some help with. https://github.com/boomshankerx/proxmox-truenas/issues/133 > > When trying to use Veeam with my custom storage plugin, the output of /api2/json/nodes/NODE/storage shows the active field as string "1" instead of int 1. This is causing tools like Veeam to fail. > > > > Is this a problem with my plugin or something further up the stack? > > > > # OUTPUT JSON > > > > { > > "data": [ > > { > > "shared": 0, > > "storage": "local", > > "content": "iso,vztmpl,backup", > > "used": 131072, > > "type": "dir", > > "enabled": 1, > > "avail": 236805029888, > > "used_fraction": 5.53501450173799e-7, > > "active": 1, > > "total": 236805160960 > > }, > > { > > "shared": 1, > > "content": "images", > > "storage": "nas.proxmox", > > "used": 0, > > "type": "nfs", > > "enabled": 1, > > "avail": 7313282826240, > > "used_fraction": 0, > > "active": 1, > > "total": 7313282826240 > > }, > > { > > "shared": 1, > > "storage": "nas", > > "content": "images", > > "used": 443571322880, > > "type": "truenas", > > "enabled": 1, > > "used_fraction": 0.0571844359724994, > > "avail": 7313282711552, > > "active": "1", > > "total": 7756854034432 > > }, > > > > ] > > } > > > > -- > > BooMShanꓘerX > > (Lorne Guse) > Hey Lorne, > > Dietmar and I investigated this: in your code [0], you > string-interpolate $active for logging before returning it. This sets > the pPOK flag, leading to the JSON encoder interpreting it as a string. > This is not an issue for $total, $available, and $used because we cast > those to int on our side [1]. > > I did not look very deeply into this, but my guess as to why we do not > cast $active as well is to allow other truthy values like 'yes', 'true', > etc - maybe someone who knows can chime in here? > > Anyway, you should be able to fix this on your side by forcing $active > into a numeric value, with int($active) or by adding 0 to it before > returning it. > > [0] https://github.com/boomshankerx/proxmox-truenas/blob/b4e73456e2de3c9ba1f589349ce5c87cd6199251/perl5/PVE/Storage/Custom/TrueNASPlugin.pm#L462 > [1] https://git.proxmox.com/?p=pve-storage.git;a=blob;f=src/PVE/Storage.pm;h=6e87bac36edf277a02a6fb5c9e600ef8281b34ad;hb=refs/heads/master#l1523 > You can run the script below to try it out for yourself ``` use strict; use warnings; use Devel::Peek; use JSON; my $json = JSON->new->canonical; print "not interpolated:\n"; { my $active = 0; my $data = { active => $active }; Dump($active); print "data: ", $json->encode($data), "\n"; } print "\ninterpolated:\n"; { my $active = 0; my $msg = "active=$active"; my $data = { active => $active}; Dump($active); print "data: ", $json->encode($data), "\n"; } ```