loganalyzer icon indicating copy to clipboard operation
loganalyzer copied to clipboard

checks: Guard float/int conversions

Open Penwy opened this issue 1 year ago • 0 comments

Description

This guards all string to float/int conversions in the analyzer inside try-except clauses, to ensure that it fails gracefully if the string fed to it is not a valid float/int.

Motivation and Context

Due to the ever-changing nature of obs logging, especially with localisation and third-party plugins, it cannot be guaranteed and future-proofed that a given search or regexp will always fetch the bit of the log that it is supposed to. If, as a result of this, the analyzer calls int() or float() on a string that is not a valid number, it will cause an exception and abort the whole analysis. For example, as a result of the french localisation adding an unexpected set of parentheses in the name of the replay buffer, this log fails the whole analysis when trying to fetch the amount of lagged frames.

This solves those instances by catching such exceptions, and allowing the rest of the analysis to proceed.

The checkStreamSettings functions haven't been modified, as they are currently not working, and #157 is already set to either modify them with an already guarded alternative, or remove them entirely.

How Has This Been Tested?

Manually fed the log above to the analyzer, checked that it worked well.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

Penwy avatar May 08 '24 16:05 Penwy