Forbid whitespaces in parameters (#3672)
This commit is contained in:
@@ -61,6 +61,7 @@ function WorkflowParameterAddPanel({ type, onClose, onSave }: Props) {
|
||||
const reservedKeys = ["current_item", "current_value", "current_index"];
|
||||
const isCloud = useContext(CloudContext);
|
||||
const [key, setKey] = useState("");
|
||||
const hasWhitespace = /\s/.test(key);
|
||||
const [urlParameterKey, setUrlParameterKey] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [bitwardenCollectionId, setBitwardenCollectionId] = useState("");
|
||||
@@ -108,6 +109,11 @@ function WorkflowParameterAddPanel({ type, onClose, onSave }: Props) {
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs text-slate-300">Key</Label>
|
||||
<Input value={key} onChange={(e) => setKey(e.target.value)} />
|
||||
{hasWhitespace && (
|
||||
<p className="text-xs text-destructive">
|
||||
Spaces are not allowed, consider using _
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs text-slate-300">Description</Label>
|
||||
@@ -398,6 +404,14 @@ function WorkflowParameterAddPanel({ type, onClose, onSave }: Props) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (hasWhitespace) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Failed to add parameter",
|
||||
description: "Key cannot contain whitespaces",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (reservedKeys.includes(key)) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
|
||||
@@ -73,6 +73,7 @@ function WorkflowParameterEditPanel({
|
||||
}: Props) {
|
||||
const isCloud = useContext(CloudContext);
|
||||
const [key, setKey] = useState(initialValues.key);
|
||||
const hasWhitespace = /\s/.test(key);
|
||||
const isBitwardenCredential =
|
||||
initialValues.parameterType === "credential" &&
|
||||
parameterIsBitwardenCredential(initialValues);
|
||||
@@ -192,6 +193,11 @@ function WorkflowParameterEditPanel({
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs text-slate-300">Key</Label>
|
||||
<Input value={key} onChange={(e) => setKey(e.target.value)} />
|
||||
{hasWhitespace && (
|
||||
<p className="text-xs text-destructive">
|
||||
Spaces are not allowed, consider using _
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label className="text-xs text-slate-300">Description</Label>
|
||||
@@ -480,6 +486,15 @@ function WorkflowParameterEditPanel({
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (hasWhitespace) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Failed to save parameter",
|
||||
description:
|
||||
"Key cannot contain whitespace characters. Consider using underscores (_) instead.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (type === "workflow") {
|
||||
if (
|
||||
parameterType === "json" &&
|
||||
|
||||
Reference in New Issue
Block a user