Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3829

No traceback and informative error when required field like description is missing

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Higher
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: N/A
    • Component/s: cfbs
    • Labels:
      None

      Description

      I should get a nice informative error telling me explicitly what is missing and what to fix when a required key is missing. Here, inside the provides key, the demo-select-business-unit-if-unassigned key is missing a description.

      ❯ cfbs add https://github.com/nickanderson/cfengine-demo-select-business-unit-if-unassigned
      Traceback (most recent call last):
        File "/home/nickanderson/.local/bin/cfbs", line 8, in <module>
          sys.exit(main())
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/main.py", line 132, in main
          return commands.add_command(
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/commands.py", line 550, in add_command
          return _add_using_url(
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/commands.py", line 514, in _add_using_url
          provides = remote_config.get_provides()
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/index.py", line 201, in get_provides
          module = _construct_provided_module(k, v, self.url, self.url_commit)
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/index.py", line 140, in _construct_provided_module
          module["description"] = data["description"]
      KeyError: 'description'
      ❯ curl -s https://raw.githubusercontent.com/nickanderson/cfengine-demo-select-business-unit-if-unassigned/main/cfbs.json
      {
        "name": "Demo select business unit if unassigned",
        "description": "Automatically select a business unit if one is not defined.",
        "type": "module",
        "provides": {
          "demo-select-business-unit-if-unassigned": {
            "tags": ["demo"],
            "repo": "https://github.com/nickanderson/cfengine-demo-select-business-unit-if-unassigned",
            "steps": [
              "copy policy/main.cf services/demo-select-business-unit-if-unassigned/main.cf",
              "json cfbs/def.json def.json"
            ]
          }
        }
      }
      
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              craig.comstock Craig Comstock
              Reporter:
              a10042 Nick Anderson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: