Page MenuHomeSoftware Heritage

Add logging when escaping data fails in BaseDb.copy_to
ClosedPublic

Authored by olasd on Aug 14 2019, 3:44 PM.

Details

Summary

When escaping a value fails when running a copy_to, there's currently
no diagnostics output. This patch adds some more information as log messages.

Test Plan

tox and tox in swh.storage with the code change

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

olasd created this revision.Aug 14 2019, 3:44 PM
vlorentz accepted this revision.Mon, Aug 19, 11:06 AM
vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/core/db/__init__.py
190–196

You may be able to do something equivalent with simpler code:

except Exception:
    logger.exception(
        'Could not escape value `%r` for column `%s`',
        value, k)
    raise
This revision is now accepted and ready to land.Mon, Aug 19, 11:06 AM
vlorentz added inline comments.Mon, Aug 19, 11:07 AM
swh/core/db/__init__.py
188

This line can probably be moved outside the try.

This revision was automatically updated to reflect the committed changes.