Skip to content

Confusing UX: func build/deploy platform restriction error lacks actionable guidance #3061

@RayyanSeliya

Description

@RayyanSeliya

Current behavior:

When running func deploy or func build with the --platform flag but without the S2I builder, the command shows an error message that doesn't help users understand what to do:

rayyan@rayyan-seliya:/mnt/c/Users/RAYYAN/Desktop/func/myfunction$ func deploy --registry ghcr.io/user --platform linux/amd64
Error: only S2I builds currently support specifying platform

This forces users to:

  1. Understand what S2I means (not explained)
  2. Guess how to enable S2I builder
  3. Not understand which builders support which features
  4. Miss the alternative of removing the flag

Proposed improvement:

Provide clear, educational guidance about platform support and builder capabilities:

Error: platform not supported by builder

The --platform flag is only supported with the S2I builder.

Try this:
  func build --registry <registry> --builder=s2i --platform linux/amd64

Or remove the --platform flag:
  func build --registry <registry>

Builder capabilities:
  s2i   Supports --platform (Source-to-Image)
  pack  Does not support --platform (uses default)
  host  Does not support --platform (uses host architecture)

For more options, run 'func build --help'

For func deploy:

Error: platform not supported by builder

The --platform flag is only supported with the S2I builder.

Try this:
  func deploy --registry <registry> --builder=s2i --platform linux/amd64

Or remove the --platform flag:
  func deploy --registry <registry>

Builder capabilities:
  s2i   Supports --platform (Source-to-Image)
  pack  Does not support --platform (uses default)
  host  Does not support --platform (uses host architecture)

For more options, run 'func deploy --help'

Solution:
Implement a 2-layer error system:

  • Layer 1 (Technical): Return ErrPlatformNotSupported from validation in pkg/functions/errors.go
  • Layer 2 (CLI): Catch the error in cmd/build.go and cmd/deploy.go and provide user-friendly guidance with examples

Expected Workflow:

According to the official documentation, using platform-specific builds requires:

  1. Use the S2I builder explicitly: func build --builder=s2i --platform linux/amd64 --registry <registry>
  2. Or use the default behavior without platform specification: func build --registry <registry>

The improved error message guides users through the correct usage.

Why S2I Only?

Different builders have different platform support capabilities:

  • S2I (Source-to-Image): Supports cross-platform builds via --platform flag for building container images targeting specific architectures
  • Pack (Buildpacks): Uses automatic platform detection and doesn't support explicit platform override
  • Host: Builds for the host machine's architecture only, no cross-platform support

User Impact:

  • Current: Cryptic error → confusion → need to search documentation → time wasted
  • Improved: Immediate understanding → clear alternatives → better developer experience → faster onboarding

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions