all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Daniel Kral" <d.kral@proxmox.com>
To: "Wolfgang Bumiller" <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [RFC PATCH common] section config: correctly handle required options in write_config
Date: Thu, 12 Mar 2026 14:25:20 +0100	[thread overview]
Message-ID: <DH0U5O36ZSCQ.1EGZG5SSFNHEM@proxmox.com> (raw)
In-Reply-To: <5au47ehnodyxkvpthlc7kxsh6ttnbzosexabjsihf64bka3ama@y2jskncbucy7>

On Thu Mar 12, 2026 at 2:06 PM CET, Wolfgang Bumiller wrote:
> On Wed, Mar 11, 2026 at 01:26:18PM +0100, Daniel Kral wrote:
>> diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm
>> index 84ff81a..d0332f9 100644
>> --- a/src/PVE/SectionConfig.pm
>> +++ b/src/PVE/SectionConfig.pm
>> @@ -1572,11 +1572,12 @@ sub write_config {
>>              next if $opts->{$k}->{optional};
>>              $done_hash->{$k} = 1;
>>              my $v = $scfg->{$k};
>> -            die "section '$sectionId' - missing value for required option '$k'\n"
>> -                if !defined($v);
>>              $v = $class->encode_value($type, $k, $v);
>
> Note that this also changes the public section config API by requiring
> `encode_value()` to deal with the `$value` parameter being `undef` -
> previously this would not happen here.

Right, good catch! I had a bad gut feeling about moving it farther here
and only did so that the die is coupled to whether
format_config_line(...) does add a line to the config $data string.

I'd go for having both the definedness check above and the 'is the data
actually written to the config file?' check below with a more telling
error message in a v2, if there are no objections.

>
> Its description would need to be updated, and its example as well, since
> it only checks the `$key` before then dereferencing `$value` as a hash.
>
> A quick grep shows a bunch of unprotected uses:
> - PVE::Storage::Plugin for `nodes` or `content{,-dirs}`
> - PVE::SDN::Zones::Plugin
> - PVE::ACME::Challenge
> - PVE::HA::Rules
> - PVE::HA::Groups
> - plugins for PVE::Job::Registry
>
>>              my $prop = $class->get_property_schema($type, $k);
>> -            $data .= format_config_line($prop, $k, $v);
>> +            my $cfg_line = format_config_line($prop, $k, $v);
>> +            die "section '$sectionId' - missing value for required option '$k'\n"
>> +                if !$cfg_line;
>> +            $data .= $cfg_line;
>>          }
>>  
>>          for my $k (@option_keys) {
>> -- 
>> 2.47.3





      reply	other threads:[~2026-03-12 13:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 12:26 Daniel Kral
2026-03-12  9:47 ` Max R. Carrara
2026-03-12 12:19   ` Daniel Kral
2026-03-12 12:54     ` Wolfgang Bumiller
2026-03-12 13:06 ` Wolfgang Bumiller
2026-03-12 13:25   ` Daniel Kral [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DH0U5O36ZSCQ.1EGZG5SSFNHEM@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal