Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trestle task csv-to-oscal-cd should give better error message when set parameter fails #1542

Open
degenaro opened this issue May 15, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@degenaro
Copy link
Collaborator

Issue description / feature objectives

Below is the current error issued by the trestle task when a invalid set parameter cell is encountered. This can be re-created by having a value with blanks, for example Cloud Network Interfaces count, in the column Parameter_Value_Default.

trestle.tasks.csv_to_oscal_cd:293 ERROR: Traceback (most recent call last):
  File "/home/degenaro/git/trestle.develop/trestle/tasks/csv_to_oscal_cd.py", line 672, in _create_set_parameters
    set_parameter = SetParameter(
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for SetParameter
param-id
  string does not match regex "^[_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$" (type=value_error.str.regex; pattern=^[_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$)

An improved error message might look like:

Traceback (most recent call last):
  File "/home/degenaro/git/trestle.develop/trestle/tasks/csv_to_oscal_cd.py", line 291, in execute
    return self._execute()
  File "/home/degenaro/git/trestle.develop/trestle/tasks/csv_to_oscal_cd.py", line 330, in _execute
    self.rules_add(rules[1])
  File "/home/degenaro/git/trestle.develop/trestle/tasks/csv_to_oscal_cd.py", line 566, in rules_add
    set_parameters = self._create_set_parameters(rule_key)
  File "/home/degenaro/git/trestle.develop/trestle/tasks/csv_to_oscal_cd.py", line 680, in _create_set_parameters
    raise RuntimeError(text)
RuntimeError: row "132" name "IBM Cloud Network Interfaces count" and/or values "['numeric']" invalid for "Parameter_Value_Default"

Caveats / Assumptions

Code fix might look like:

image

Completion Criteria

  • Improved error message is provided.
  • Test case coverage.
@jpower432 jpower432 added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels May 31, 2024
@jpower432 jpower432 added this to the v3.1.0 milestone May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants