Skip to content

Rule blocked: DDF00085 - get_xhtml_errors operation fails for missing values #1435

@ASL-rmarshall

Description

@ASL-rmarshall

Links to related JIRA Tickets

Rule Information

  • Standard: USDM
  • Rule ID: DDF00085
  • Rule Description: Narrative content text is expected to be HTML formatted.

Describe the bug
When the attribute/variable specified in the name parameter for the get_xhtml_errors operation contains missing values (NULL, None, NaN, etc.), the following error occurs and the dataset is skipped:

AttributeError: 'NoneType' object has no attribute 'strip'

The error occurs because each input value is stripped before its presence is verified:

def _ensure_dataset_is_valid_xhtml(self, value: str) -> list[str]:
value: str = value.strip()
if not value:
return []
text = value.strip()
if not text:
return []

The stripping on line 73 is redundant (it's done again on line 77) and should be removed.

Error returned from Rule Engine

{
    "NarrativeContent": [
        {
            "executionStatus": "skipped",
            "dataset": "NarrativeContent.xpt",
            "domain": "",
            "variables": [],
            "message": "rule evaluation skipped - missing metadata",
            "errors": [
                {
                    "dataset": "NarrativeContent.xpt",
                    "error": "Missing field during execution",
                    "message": "Missing field during execution, rule may not be applicable- unable to process dataset"
                }
            ]
        }
    ]
}

Expected behavior
The operation should not fail when there are missing values in the in specified input variable/attribute.

Request.json including test data
Request.json

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions