Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/containerconfig/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ func parseComposeFile(composePath string) (*ComposeFile, error) {

var compose ComposeFile
if err := yaml.Unmarshal(data, &compose); err != nil {
return nil, fmt.Errorf("failed to parse compose file: %w", err)
// Try to extract more detailed error information from yaml.TypeError
if typeErr, ok := err.(*yaml.TypeError); ok && len(typeErr.Errors) > 0 {
return nil, fmt.Errorf("YAML syntax error in compose file %s: %s", composePath, typeErr.Errors[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it have multiple errors in Errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could, I'm fine with returning only the first error. Do you see this as a problem?

Copy link
Member

@kzys kzys Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If the parser can detect multiple errors, it makes sense to show all of them instead of hiding.

}
// Provide the file path and line/column info if available in the error message
return nil, fmt.Errorf("YAML syntax error in compose file %s: %w", composePath, err)
}

return &compose, nil
Expand Down
3 changes: 2 additions & 1 deletion internal/containerconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func ParseContainerConfig(mConfig *fly.MachineConfig, composePath, machineConfig
composePath = filepath.Join(configDir, composePath)
}
if err := ParseComposeFileWithPath(mConfig, composePath); err != nil {
return err
// Add more context to compose file errors
return fmt.Errorf("failed to load compose file '%s': %w", composePath, err)
}
} else if machineConfigStr != "" {
// Fall back to machine config if specified
Expand Down
Loading