Skip to content

WIP: nonEmpty param option support#10678

Open
Berlioz wants to merge 3 commits into
mainfrom
vsfan_nonempty_params
Open

WIP: nonEmpty param option support#10678
Berlioz wants to merge 3 commits into
mainfrom
vsfan_nonempty_params

Conversation

@Berlioz

@Berlioz Berlioz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Also gets rid of that immutable copy-paste mistake which has never done anything.

@Berlioz Berlioz requested review from ajperel and inlined June 17, 2026 22:49

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 'nonEmpty' option to parameter definitions to reject empty strings and empty arrays during CLI prompting, propagating this configuration through various prompt helper functions. The review feedback highlights a critical TypeScript compilation error caused by changing the signature of 'promptResourceString' (which breaks an existing caller), and suggests correcting an inaccurate error message in 'promptSelectMultiple' when no options are selected.

Comment thread src/deploy/functions/params.ts
Comment thread src/deploy/functions/params.ts

@inlined inlined left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I recommend that nonEmpty is a part of input? we can talk offline.

prompt += ` \n(${param.description})`;
}
return promptText<boolean>(prompt, param.input, resolvedDefault, isTruthyInput);
return promptText<boolean>(prompt, param.input, resolvedDefault, false, isTruthyInput);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please always leave a comment on any boolean literal ever used as a parameter

prompt: string,
input: ResourceInput,
projectId: string,
disallowEmpty: boolean | undefined,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disallowEmpty and nonEmpty? Also, why mandatory but supports undefined?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah (naming aside) this could just be disallowEmpty: boolean = false so there's a default value for the case where we have undefined from it not being in functions.yaml right? (same elsewhere).

I have a hunch on why the name change from nonEmpty to disallowEmpty but I'd like to hear Victor's answer :) ... I do think it's a debateable shift.

input?: ParamInput<T>;

// Reject the empty string and empty array as valid input.
nonEmpty?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how hard it is to make the field only present for the right types. At minimum you can say:

type TypeIfExtends<Result, Test, Base> = Test extends Base ? Result : never;

// ...
nonEmpty: TypeIfExtends<boolean, T, string | string[]>

prompt,
param.input,
resolvedDefault,
param.nonEmpty,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is nonEmpty not part of input?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is (which from what I understand with a bit of research I would support) do we also need to update the API proposal to be clear about that?

Or we enforce nonEmpty at deployment time and not just input prompting time?

I guess a difference between functions and extensions is users can edit params after the input form by hand editing .env files (or could add nonEmpty after a first deployment that writes an empty string).

@ajperel ajperel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chiming in with a few thoughts since I went through this PR trying to understand it. But overall, I think just having Thomas's LG (and not blocking on more review from me) is fine.

prompt: string,
input: ResourceInput,
projectId: string,
disallowEmpty: boolean | undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah (naming aside) this could just be disallowEmpty: boolean = false so there's a default value for the case where we have undefined from it not being in functions.yaml right? (same elsewhere).

I have a hunch on why the name change from nonEmpty to disallowEmpty but I'd like to hear Victor's answer :) ... I do think it's a debateable shift.

prompt,
param.input,
resolvedDefault,
param.nonEmpty,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is (which from what I understand with a bit of research I would support) do we also need to update the API proposal to be clear about that?

Or we enforce nonEmpty at deployment time and not just input prompting time?

I guess a difference between functions and extensions is users can edit params after the input form by hand editing .env files (or could add nonEmpty after a first deployment that writes an empty string).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants