@@ -271,6 +271,12 @@ func InvalidProjectNameErr(v string) error {
271271 )
272272}
273273
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.
274280func projectName (details types.ConfigDetails , opts * Options ) (string , error ) {
275281 projectName , projectNameImperativelySet := opts .GetProjectName ()
276282
@@ -281,10 +287,22 @@ func projectName(details types.ConfigDetails, opts *Options) (string, error) {
281287 for _ , configFile := range details .ConfigFiles {
282288 yml , err := ParseYAML (configFile .Content )
283289 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
284294 return "" , nil
285295 }
286296 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
288306 }
289307 }
290308 if ! opts .SkipInterpolation {
0 commit comments