close
Skip to content

nonEmpty param input option support - #10678

Merged
Berlioz merged 12 commits into
mainfrom
vsfan_nonempty_params
Jul 10, 2026
Merged

nonEmpty param input option support#10678
Berlioz merged 12 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 Outdated

@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.

Comment thread src/deploy/functions/params.ts Outdated
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack

Comment thread src/deploy/functions/params.ts Outdated
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think changing the var name from nonEmpty to disallowEmpty as it moves from the wire format into the function calling chain makes sense: nonEmpty is describing something about the input itself, while disallowEmpty is more a modifier on the behavior of the prompt: "this prompt is nonempty" seems more vague than "this prompt disallows empty".

That's very much a subjective take though and if you two feel like it's an unnecessary or bad naming decision I really don't mind reverting it.

The boolean | undefined thing was just me being dumb and forgetting that typescript had optional parameters for a second. Fixed.

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.

I get the move from describing the input to enforcing the constraint (that was what I thought you were doing). I'd say if we want to make that distinction we could have a slightly better throughline with a different name.

nonEmpty -> enforceNonEmpty or something like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh, yeah, that's a good compromise

Comment thread src/deploy/functions/params.ts Outdated
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[]>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not as confident about reading type system stuff as you are but my instinct is that this is a huge loss of readability to double-enforce a constraint that the SDK can already enforce much more clearly.

Comment thread src/deploy/functions/params.ts Outdated
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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Update: we talked it out, updated the SDK, and yeah, moved to input fields.

@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.

Comment thread src/deploy/functions/params.ts Outdated
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.

Comment thread src/deploy/functions/params.ts Outdated
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).

@Berlioz Berlioz changed the title WIP: nonEmpty param option support nonEmpty param input option support Jul 6, 2026
Comment thread src/deploy/functions/params.ts Outdated
prompt,
param.input,
resolvedDefault,
false, // enforceNonEmpty

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.

Doesn't text input support nonempty?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure does. Straight up copy-paste error.

Comment thread src/deploy/functions/params.ts Outdated
return promptSelectMultiple<string>(
prompt,
forgedInput,
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.

please comment on what parameter a literal is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack

Comment thread src/deploy/functions/params.ts Outdated
`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`,
);
return promptText<string[]>(prompt, { text: {} }, undefined, (res: string) => res.split(","));
return promptText<string[]>(prompt, { text: {} }, undefined, enforceNonEmpty, (res: string) =>

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.

same. Comment on what undefined is (I know this is preexisting)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack

Comment thread src/deploy/functions/params.ts Outdated
}
}
if (enforceNonEmpty && res === "") {
logger.error(`Input cannot be the empty string, retrying...`);

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.

Can we be a little less nerdy? E.g. "A value is required, retrying..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack

@Berlioz
Berlioz enabled auto-merge (squash) July 10, 2026 20:36
@Berlioz
Berlioz disabled auto-merge July 10, 2026 20:43
@Berlioz
Berlioz merged commit a68434e into main Jul 10, 2026
53 checks passed
@Berlioz
Berlioz deleted the vsfan_nonempty_params branch July 10, 2026 20:53
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