Skip to content

lineage_validator - confusing stack trace when the Association is incorrect #42

@greg-infa

Description

@greg-infa

Hi Darren,

When the Association in validated file is incorrect (for example Core.DataSetDataFlow instead of core.DataSetDataFlow) then EDC returns 500 error, as a response for association query (/access/2/catalog/data/objects inside validate_edc_id.
The script throws a confusing stack trace in this case:

Traceback (most recent call last):
  File "lineage_validator.py", line 396, in <module>
    main()
  File "lineage_validator.py", line 111, in main
    validate_lineage_file(args.lineage_file)
  File "lineage_validator.py", line 161, in validate_lineage_file
    validated_row = validate_lineage_row(row)
  File "lineage_validator.py", line 233, in validate_lineage_row
    row_to_validate["From Object"], row_to_validate["Association"]
  File "lineage_validator.py", line 359, in validate_edc_id
    return (is_valid, message, result)
UnboundLocalError: local variable 'result' referenced before assignment

It can be modified like this (still not perfect, but anyway):

    if tResp.status_code == 200:
        result = json.loads(tResp.text)
        object_count = result["metadata"]["totalCount"]
        if object_count == 1:
            is_valid = "True"
    else:
        print('EDC query failed with response code %d !!!' % tResp.status_code)
        if tResp.text:
            print("Response text %s" % tResp.text)
        exit(13)

so it still fails (as it should), but the message is more meaningful:

EDC query failed with response code 500 !!!
Response text {"timestamp":1678184006345,"status":500,"error":"Internal Server Error","message":"java.util.NoSuchElementException: AssociationKind not found: Core.DataSetDataFlow","path":"/access/2/catalog/data/objects"}

Regards
Greg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions