Skip to content

Commit 9dcb6cf

Browse files
committed
avoid white-space only input in snowflake config
1 parent 1811615 commit 9dcb6cf

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/messageTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export type LocalizedMessages = {
234234
integrationsSnowflakeRolePlaceholder: string;
235235
integrationsSnowflakeWarehouseLabel: string;
236236
integrationsSnowflakeWarehousePlaceholder: string;
237+
integrationsSnowflakeUnnamedIntegration: string;
237238
// Common form strings
238239
integrationsRequiredField: string;
239240
integrationsOptionalField: string;

src/webviews/webview-side/integrations/SnowflakeForm.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
110110
const handleSubmit = (e: React.FormEvent) => {
111111
e.preventDefault();
112112

113-
const unnamedIntegration = format('Unnamed Snowflake Integration ({0})', integrationId);
113+
const unnamedIntegration = getLocString(
114+
'integrationsSnowflakeUnnamedIntegration',
115+
'Unnamed Snowflake Integration ({0})'
116+
);
114117

115118
let config: SnowflakeIntegrationConfig;
116119

117-
if (authMethod === null || authMethod === SnowflakeAuthMethods.PASSWORD) {
120+
if (authMethod === SnowflakeAuthMethods.PASSWORD) {
118121
config = {
119122
id: integrationId,
120-
name: (name || unnamedIntegration).trim(),
123+
name: (name || format(unnamedIntegration, integrationId)).trim(),
121124
type: 'snowflake',
122125
account: account.trim(),
123126
authMethod: authMethod,
@@ -128,9 +131,14 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
128131
role: role.trim() || undefined
129132
};
130133
} else if (authMethod === SnowflakeAuthMethods.SERVICE_ACCOUNT_KEY_PAIR) {
134+
// Guard against empty private key
135+
if (!privateKey.trim()) {
136+
return;
137+
}
138+
131139
config = {
132140
id: integrationId,
133-
name: (name || unnamedIntegration).trim(),
141+
name: (name || format(unnamedIntegration, integrationId)).trim(),
134142
type: 'snowflake',
135143
account: account.trim(),
136144
authMethod: authMethod,
@@ -186,6 +194,7 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
186194
placeholder={getLocString('integrationsSnowflakeAccountPlaceholder', 'abcd.us-east-1')}
187195
autoComplete="off"
188196
required
197+
pattern=".*\S.*"
189198
disabled={isUnsupported}
190199
/>
191200
</div>
@@ -225,6 +234,7 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
225234
placeholder={getLocString('integrationsSnowflakeUsernamePlaceholder', '')}
226235
autoComplete="username"
227236
required
237+
pattern=".*\S.*"
228238
/>
229239
</div>
230240

@@ -241,6 +251,7 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
241251
placeholder={getLocString('integrationsSnowflakePasswordPlaceholder', '•••••')}
242252
autoComplete="current-password"
243253
required
254+
pattern=".*\S.*"
244255
/>
245256
</div>
246257
</>
@@ -268,6 +279,7 @@ export const SnowflakeForm: React.FC<ISnowflakeFormProps> = ({
268279
placeholder={getLocString('integrationsSnowflakeServiceAccountUsernamePlaceholder', '')}
269280
autoComplete="username"
270281
required
282+
pattern=".*\S.*"
271283
/>
272284
</div>
273285

0 commit comments

Comments
 (0)