@@ -271,6 +271,12 @@ func InvalidProjectNameErr(v string) error {
271
271
)
272
272
}
273
273
274
+ // projectName determines the canonical name to use for the project considering
275
+ // the loader Options as well as `name` fields in Compose YAML fields (which
276
+ // also support interpolation).
277
+ //
278
+ // TODO(milas): restructure loading so that we don't need to re-parse the YAML
279
+ // here, as it's both wasteful and makes this code error-prone.
274
280
func projectName (details types.ConfigDetails , opts * Options ) (string , error ) {
275
281
projectName , projectNameImperativelySet := opts .GetProjectName ()
276
282
@@ -281,10 +287,22 @@ func projectName(details types.ConfigDetails, opts *Options) (string, error) {
281
287
for _ , configFile := range details .ConfigFiles {
282
288
yml , err := ParseYAML (configFile .Content )
283
289
if err != nil {
290
+ // HACK: the way that loading is currently structured, this is
291
+ // a duplicative parse just for the `name`. if it fails, we
292
+ // give up but don't return the error, knowing that it'll get
293
+ // caught downstream for us
284
294
return "" , nil
285
295
}
286
296
if val , ok := yml ["name" ]; ok && val != "" {
287
- pjNameFromConfigFile = yml ["name" ].(string )
297
+ sVal , ok := val .(string )
298
+ if ! ok {
299
+ // HACK: see above - this is a temporary parsed version
300
+ // that hasn't been schema-validated, but we don't want
301
+ // to be the ones to actually report that, so give up,
302
+ // knowing that it'll get caught downstream for us
303
+ return "" , nil
304
+ }
305
+ pjNameFromConfigFile = sVal
288
306
}
289
307
}
290
308
if ! opts .SkipInterpolation {
0 commit comments