Skip to content

Commit ad968d9

Browse files
joehantonyjhuang
authored andcommitted
Ensure spec.params and spec.systemParams are not empty (#5715)
1 parent b2d995e commit ad968d9

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- Fixes an issue where Secret Manager secrets were tagged incorrectly (#5704).
44
- Fix bug where Custom Event channels weren't automatically crated on function deploys (#5700)
55
- Lift GCF 2nd gen naming restrictions (#5690)
6+
- Fixes a bug where `ext:install` and `ext:configure` would error on extensions with no params.

src/commands/ext-configure.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ export const command = new Command("ext:configure <extensionInstanceId>")
7575
instanceId,
7676
projectDir: config.projectDir,
7777
});
78-
7978
const [immutableParams, tbdParams] = partition(
80-
spec.params.concat(spec.systemParams ?? []),
79+
(spec.params ?? []).concat(spec.systemParams ?? []),
8180
(param) => param.immutable ?? false
8281
);
8382
infoImmutableParams(immutableParams, oldParamValues);

src/commands/ext-install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async function installToManifest(options: InstallExtensionOptions): Promise<void
207207

208208
const paramBindingOptions = await paramHelper.getParams({
209209
projectId,
210-
paramSpecs: spec.params.concat(spec.systemParams ?? []),
210+
paramSpecs: (spec.params ?? []).concat(spec.systemParams ?? []),
211211
nonInteractive,
212212
paramsEnvPath,
213213
instanceId,

src/extensions/extensionsApi.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,20 @@ async function patchInstance(args: {
365365
return pollRes;
366366
}
367367

368-
function populateResourceProperties(spec: ExtensionSpec): void {
368+
function populateSpec(spec: ExtensionSpec): void {
369369
if (spec) {
370-
spec.resources.forEach((r) => {
370+
for (const r of spec.resources) {
371371
try {
372372
if (r.propertiesYaml) {
373373
r.properties = yaml.safeLoad(r.propertiesYaml);
374374
}
375375
} catch (err: any) {
376376
logger.debug(`[ext] failed to parse resource properties yaml: ${err}`);
377377
}
378-
});
378+
}
379+
// We need to populate empty repeated fields with empty arrays, since proto wire format removes them.
380+
spec.params = spec.params ?? [];
381+
spec.systemParams = spec.systemParams ?? [];
379382
}
380383
}
381384

@@ -405,7 +408,7 @@ export async function createSource(
405408
masterTimeout: 600000,
406409
});
407410
if (pollRes.spec) {
408-
populateResourceProperties(pollRes.spec);
411+
populateSpec(pollRes.spec);
409412
}
410413
return pollRes;
411414
}
@@ -418,7 +421,7 @@ export async function createSource(
418421
export async function getSource(sourceName: string): Promise<ExtensionSource> {
419422
const res = await apiClient.get<ExtensionSource>(`/${sourceName}`);
420423
if (res.body.spec) {
421-
populateResourceProperties(res.body.spec);
424+
populateSpec(res.body.spec);
422425
}
423426
return res.body;
424427
}
@@ -434,7 +437,7 @@ export async function getExtensionVersion(extensionVersionRef: string): Promise<
434437
try {
435438
const res = await apiClient.get<ExtensionVersion>(`/${refs.toExtensionVersionName(ref)}`);
436439
if (res.body.spec) {
437-
populateResourceProperties(res.body.spec);
440+
populateSpec(res.body.spec);
438441
}
439442
return res.body;
440443
} catch (err: any) {

0 commit comments

Comments
 (0)