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

Better handling of None value when formatting XuleValue value #37

Conversation

aaroncameron-wk
Copy link

Description

XuleValue.format_value will throw an error for most value types when calling format_value with a self.value of None.

Example stacktrace:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 252, in evaluate_rule_set
    evaluate(rule, xule_context)
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 643, in evaluate
    value = EVALUATOR[rule_part_name](rule_part, xule_context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 920, in evaluate_assertion
    messages[rule_result[\'resultName\']] = result_message(assert_rule, rule_result, xule_value,
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 5294, in result_message
    message_value = evaluate(result_ast[\'resultExpr\'], message_context)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 643, in evaluate
    value = EVALUATOR[rule_part_name](rule_part, xule_context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 1202, in evaluate_string_literal
    expr_value = evaluate(string_item, xule_context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 643, in evaluate
    value = EVALUATOR[rule_part_name](rule_part, xule_context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 4452, in evaluate_property
    object_value = process_property(current_property_expr, object_value, property_info, xule_context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProcessor.py", line 4530, in process_property
    object_value = property_info[XuleProperties.PROP_FUNCTION](xule_context, object_value, *arg_values)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleProperties.py", line 381, in property_join
    result_string += next_sep + k.format_value() + pair_sep.value + v.format_value()
                                                                    ^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/xule/XuleValue.py", line 520, in format_value
    return str(self.value.qname)
               ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'qname'

@campbellpryde
@davidtauriello

@phillipengel
Copy link
Contributor

This fix will fix the symptom, BUT, a XuleValue.value should not be None if its type is not 'none'. So, I think the real problem lies elsewhere. Can you provide an example that causes this error?

@aaroncameron-wk
Copy link
Author

aaroncameron-wk commented Apr 7, 2025

Can you provide an example that causes this error?

Unfortunately the document that triggered this is a pre-release filing which I can not easily obtain access to, nor do I have the knowledge to create an example myself. It may very well be that the document was in a very poor/incomplete state, in which case it would be preferable to have format_value be hardened so that the issue can be captured and reported elsewhere.

davidtauriello added a commit to davidtauriello/xule that referenced this pull request Apr 8, 2025
davidtauriello added a commit that referenced this pull request Apr 8, 2025
* Update rulesetMap.json

- v26 as default install
- update ESEF-DQC.py to use rulesetMap.json

* Update xodel.py

 - Filter captured logs to include only INFO level messages

* Update for XULE 30047

- address #35 and #37
@davidtauriello
Copy link
Contributor

@aaroncameron-wk - this was addressed in release 30047

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants