ascmitc / mhl

ASC Media Hash List
MIT License
58 stars 8 forks source link

create command crash #113

Closed jmccdev closed 2 years ago

jmccdev commented 2 years ago

Files are available under the ASC MHL G-Drive, under 'Test-Media > Interop Test Cases':

$ ascmhl create sources/
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/ascmhl", line 11, in <module>
    sys.exit(mhltool_cli())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/commands.py", line 96, in create
    create_for_folder_subcommand(root_path, verbose, hash_format, no_directory_hashes, ignore_list, ignore_spec_file)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/commands.py", line 121, in create_for_folder_subcommand
    existing_history = MHLHistory.load_from_path(root_path)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/history.py", line 244, in load_from_path
    history._find_and_load_child_histories()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/history.py", line 294, in _find_and_load_child_histories
    child_history = MHLHistory.load_from_path(root)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/history.py", line 244, in load_from_path
    history._find_and_load_child_histories()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/history.py", line 301, in _find_and_load_child_histories
    self._resolve_hash_list_references()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ascmhl/history.py", line 329, in _resolve_hash_list_references
    assert referenced_hash_list.generate_reference_hash() == reference.reference_hash
AssertionError
jwaggs commented 2 years ago

@ptrpfn I think we should comb through the code to remove any assertion statements in favor of raising explicit errors if they cannot be handled.

I like to limit assertions to test cases.

ptrpfn commented 2 years ago

@jmccdev Can you add the invocation (params, paths etc.) of the ascmhl create command? Everything that helps reproducing it would be good.

jmccdev commented 2 years ago

original post updated with the command

ptrpfn commented 2 years ago

The reason for the crash was in test case 105b. Currently the ascmhl tool did catch the case if a mhl file has a different hash than the hash noted in a hash reference, but it simply asserted instead of displaying an error.

The problem: MHL file sources/nested_histories/105b/16421225_Day001/ascmhl/0001_16421225_Day001_2022-02-09_040703.mhl references MHL file sources/nested_histories/105b/16421225_Day001/Camera_Media/A007_0124J4/ascmhl/0002_A007_0124J4_2022-02-09_040703.mhl with a c4 hash of c43Tp4c9dPJv4or8D35tzSNNPqSdW9DxZX5ZG7qSp9jnqetKTAfUVCEHWXvBX9xNEzpmeM9uBtai7fswWPBfs8wvkW but the actual hash of the file 0002_A007_0124J4_2022-02-09_040703.mhl is c434WT7GH925LAHEeSwmJppq1WMT7EPD5FpFRZdWpq2j2Ejsapb4kW2xn3JrmUmY3sS2GgoFAXUiQQo8K6GXmVJGrm .

Pull request PR #117 fixes the issue by adding error log in case this happens and doesn't assert any more.

TBD: Decide if the tool should abort or continue (in PR #117 it continues), and what the exit code should be. Added this topic to agenda of the the next group meeting.

ptrpfn commented 2 years ago

Fixed with PR #117.