Hi, it seems that when running flows locally with ...
# ask-community
a
Hi, it seems that when running flows locally with the Prefect CLI it will abort if passed parameters that don't exist in the flow, but when running registered flows it will pass them through and run with no errors. Is there a way for the CLI to validate parameters and show an error if a param doesn't exist? We'd like to catch this in case someone passes a misspelled param name, for example.
Copy code
# Running the flow locally
aric@aric-dev:~/src/conductor$ prefect run -p conductor/samples/hello_world_flow.py --param foo=bar
Retrieving local flow... Done
Configured local flow run
└── Parameters: {'foo': 'bar'}
Running flow locally...
Flow runner encountered an exception!
  Traceback (most recent call last):
    File "/home/aric/.local/lib/python3.8/site-packages/prefect/cli/run.py", line 590, in run
    result_state = flow.run(parameters=params_dict)
    File "/home/aric/.local/lib/python3.8/site-packages/prefect/core/flow.py", line 1250, in run
    raise ValueError(
  ValueError: Flow.run received the following unexpected parameters: foo

Flow run failed!

# Running the same flow registered on Prefect Cloud
aric@aric-dev:~/src/conductor$ prefect run -n "Hello World" --param foo=bar
Looking up flow metadata... Done
Creating run for flow 'Hello World'... Done
└── Name: monumental-bat
└── UUID: 39c7896b-0bee-4015-be99-648d90da201b
└── Labels: []
└── Parameters: {'foo': 'bar'}
└── Context: {}
└── URL: <https://cloud.prefect.io/><URL>
z
Hi @Aric Huang -- this just matches the behavior of the backing API and I'm hesitant to make the CLI do something different. I'll take a look at the reasoning behind the backend behavior though!
a
I see, thanks for looking into it!
Having this validation would be helpful for our use case since the people who would be running flows prefer using CLI tools and may not be looking in the UI at what params are available
z
That makes sense. I'll see how feasible it is to add.