Page MenuHomePhorge

Fix crash when upload failed
ClosedPublic

Authored by nannanko on Jul 6 2024, 5:10 PM.

Details

Summary

When response isn't an valid json, nlohmann::json::parse() will cause a crash. This fixed it.

Type: fix

Test Plan

Verify that kazv doesn't crash when upload failed.

Diff Detail

Repository
rK kazv
Branch
servant
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 148
Build 285: GitLab CI for kazv
Build 284: arc lint + arc unit

Event Timeline

There is currently a lack of unit tests, and I'm not sure how to write them at the moment. I will add all related tests for uploading and downloading soon.

src/kazv-io-job.cpp
298–302

Why not use try-catch?

Also Better to log it.

303

Don't assume the json body is in valid format. There are plenty of things that can go wrong.

tusooa requested changes to this revision.Jul 6 2024, 5:41 PM
This revision now requires changes to proceed.Jul 6 2024, 5:41 PM
  • Use try-catch for exception
tusooa requested changes to this revision.Jul 12 2024, 7:08 AM
tusooa added inline comments.
src/kazv-io-job.cpp
304

Note, your original code doesn't create a default-constructed json. This creates an empty json array instead.

309

should be qCWarning(kazvLog)

313
314
317

should be qCWarning(kazvLog)

src/l10n/en/100-ui.ftl
212

missing translations for cmn-Hans

This revision now requires changes to proceed.Jul 12 2024, 7:08 AM
  • Add cmn-Hans translations
  • Use qCWarning instead of qDebug
  • Check json format, fix a template call
This revision is now accepted and ready to land.Jul 13 2024, 9:08 AM
This revision was automatically updated to reflect the committed changes.