CumulusCI icon indicating copy to clipboard operation
CumulusCI copied to clipboard

CCI Inconsistencies in validating arguments

Open prescod opened this issue 5 years ago • 1 comments

CCI does not validate task options which come from CumulusCI.yml or Python, but it does validate options that come from the CLI or Robot.

Given dummy_task.py:

from cumulusci.core.tasks import BaseTask
from cumulusci.tasks.bulkdata.tests.test_bulkdata import _make_task


class DummyTask(BaseTask):
    task_options = {"color": {}}

    def _run_task(self):
        print(self.options)


if __name__ == "__main__":
    task = _make_task(
        DummyTask,
        {
            "options": {
                "color": "red",
                "colour": "icywhite",
            }
        },
    )
    task()

This will print a dict with both colo(u)rs in it.

If you invoke it in a CCI task you'll get the same thing:

    dummy_task:
      class_path: dummy_task.DummyTask
      options:
        color: Red
        colour: MapleSyrupBrown

But if you try to set both options from the command line, you'll get an error:

cci task run dummy_task -o color white -o colour PoutineBrown
Usage: cci task run [OPTIONS] TASK_NAME

Error: Option "colour" is not available for task dummy_task

The same is true for Robot, but demonstrating this is an exercise for the reader.

prescod avatar Jan 03 '20 14:01 prescod

This is because this aspect of option validation happens in cci.py and cumulusci/robotframework/CumulusCI.py rather than in the task infrastructure itself.

prescod avatar Jan 03 '20 14:01 prescod