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

Parameter 'crypto_fee' has zero value #101

Open
splix opened this issue Sep 4, 2023 · 3 comments · May be fixed by #102
Open

Parameter 'crypto_fee' has zero value #101

splix opened this issue Sep 4, 2023 · 3 comments · May be fixed by #102

Comments

@splix
Copy link

splix commented Sep 4, 2023

rp2_us fails with error:

INFO: Country: us
INFO: Generation Language: en
INFO: Accounting method: fifo
INFO: Configuration file: ../reports/test_crypto_data.ini
INFO: Input file: ../reports/test_crypto_data.ods
INFO: Processing ETH
ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/rp2/rp2_main.py", line 143, in _rp2_main_internal
    input_data: InputData = parse_ods(configuration=configuration, asset=asset, input_file_handle=input_file_handle)
  File "/usr/local/lib/python3.10/site-packages/rp2/ods_parser.py", line 127, in parse_ods
    _create_and_process_transaction(
  File "/usr/local/lib/python3.10/site-packages/rp2/ods_parser.py", line 166, in _create_and_process_transaction
    transaction: AbstractTransaction = _create_transaction(configuration, current_table_type, internal_id, row_values)
  File "/usr/local/lib/python3.10/site-packages/rp2/ods_parser.py", line 286, in _create_transaction
    transaction = OutTransaction(**argument_pack)
  File "/usr/local/lib/python3.10/site-packages/rp2/out_transaction.py", line 60, in __init__
    self.__crypto_fee = configuration.type_check_positive_decimal("crypto_fee", crypto_fee, non_zero=True)
  File "/usr/local/lib/python3.10/site-packages/rp2/configuration.py", line 468, in type_check_positive_decimal
    raise RP2ValueError(f"Parameter '{name}' has zero value")
rp2.rp2_error.RP2ValueError: Parameter 'crypto_fee' has zero value

I've checked the file and it doesn't have any line with zero value, but there are few lines with a very small value. That may be the reason, but anyway it's hard to find out where is the problem with such error message.

I suggest to include the actual string which rp2 failed to parse in the error message. And if it's possible the line number from the file.

@eprbell
Copy link
Owner

eprbell commented Sep 5, 2023

Thanks for reporting. Could you run with debug logs enabled? Logs are stored in the log directory. To generate debug logs, prepend the command line with LOG_LEVEL=DEBUG, e.g.:

LOG_LEVEL=DEBUG rp2_us -o output -p crypto_example_ config/crypto_example.ini input/crypto_example.ods

Then open the log and check the end of it (probably the last line): it should give us clues as to what is happening. Before posting here any personal data please read this and feel free to sanitize your logs to skip sensitive info.

@splix
Copy link
Author

splix commented Sep 5, 2023

Turns out there were a zero value, but for a some reason LibreOffice wasn't able to find it. So it's not a RP2 bug.

So just to improve the situation, maybe it worth adding the line number to the error?

I tried something like that to ods_parser.py:125:

try:
    # Transaction line
    _create_and_process_transaction(
        configuration, row_values, current_table_type, i   1, artificial_internal_id, unfiltered_transaction_sets, artificial_transaction_list
    )
except RP2Error as exc:
    raise RP2ValueError(f"{asset}({i   1}): {exc}") from exc

It helped me to find the incorrect line. I see a similar catch in other lines, but not for _create_and_process_transaction call, not sure what is the reason.

@eprbell
Copy link
Owner

eprbell commented Sep 6, 2023

Glad you found the problem. Also what you suggest is a good improvement: can you open a PR? Thanks.

splix added a commit to splix/rp2 that referenced this issue Sep 16, 2023
@splix splix linked a pull request Sep 16, 2023 that will close this issue
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 a pull request may close this issue.

2 participants