knative/func

Bug: Wrong error message when running func commands if the function is not initialized

Opened this issue · 2 comments

Issue Summary:

When executing the commands func deploy, func run, and func build without first initializing a function (missing func.yaml file due to not running func create or func init), the error handling leads to an unclear message. This occurs even if the commands are typed correctly.

Current Behavior:

Attempting to run any of the above commands without initializing a function results in a misleading error message related to registry validation:

func build -b=s2i -v
A registry for function images is required. For example, 'docker.io/tigerteam'.
X Sorry, your reply was invalid: invalid registry ["quay.io/user-abc"]: name required
? Registry for function images:

The error message should clearly indicate that the function has not been initialized and provide guidance on the necessary steps to proceed.

Proposed Solution:

Improve the error message to more accurately reflect the issue and guide the user. Suggested new error message:

Error: No function has been initialized in the current directory ({path}). Please initialize a function by running either:
- func init --language <your language>
- func create <function name> --language <language>

Thanks @Leo6Leo,

This does look like a logic problem. There should be a different error there.

I've added this to the roadmap

I would like to work on this issue!