@@ -436,6 +436,45 @@ distribution::
436
436
tox
437
437
438
438
439
+ Troubleshooting
440
+ ---------------
441
+
442
+ The most common problem with *jsonmerge * is getting unexpected results from
443
+ a merge. Finding the exact reason why *jsonmerge * produced a particular
444
+ result can be complicated, especially when head and base structures are
445
+ very large. Most often the cause is a problem with either the schema or
446
+ head and base that is passed to *jsonmerge *, not a bug in *jsonmerge *
447
+ itself.
448
+
449
+ Here are some tips for debugging issues with *jsonmerge *:
450
+
451
+ * Try to minimize the problem. Prune branches of head and base structures
452
+ that are not relevant to your issue and re-run the merge. Often just
453
+ getting a clearer view of the relevant parts exposes the problem.
454
+
455
+ * *jsonmerge * uses the standard `logging `_ Python module to print out what
456
+ it is doing during the merge. You need to increase verbosity to DEBUG
457
+ level to see the messages.
458
+
459
+ * A very common mistake is misunderstanding which part of the schema
460
+ applies to which part of the head and base structures. Debug logs
461
+ mentioned in the previous point can be very helpful with that, since they
462
+ show how merge descends into hierarchies of all involved structures and
463
+ when a default strategy is used.
464
+
465
+ * With large head and base it's common that parts of them are not what you
466
+ think they are. Validate your inputs against your schema using the
467
+ *jsonschema * library before passing them onto *jsonmerge *. Make sure your
468
+ schema is restrictive enough.
469
+
470
+ * Pay special attention to parts of the schema that use *oneOf *, *anyOf *,
471
+ *allOf * keywords. These can sometimes validate in unexpected ways.
472
+
473
+ * Another problem point can be *$ref * pointers if they can cause recursion.
474
+ Using recursive schemas with *jsonmerge * is fine, but they can often
475
+ product unexpected results.
476
+
477
+
439
478
Reporting bugs and contributing code
440
479
------------------------------------
441
480
@@ -445,14 +484,21 @@ that I maintain this project in my free time. Hence I ask you to follow
445
484
this simple etiquette to minimize the amount of effort needed to include
446
485
your contribution.
447
486
448
- Please use `GitHub issues `_ to report bugs. Make sure that your report
449
- includes:
487
+ Please use `GitHub issues `_ to report bugs.
488
+
489
+ Before reporting the bug, please make sure that:
490
+
491
+ * You've read this entire README file.
492
+ * You've read the Troubleshooting section of the README file.
493
+ * You've looked at existing issues if the bug has already been reported.
494
+
495
+ Make sure that your report includes:
450
496
451
497
* A *minimal *, but complete, code example that reproduces the problem,
452
498
including any JSON data required to run it. It should be something I can
453
499
copy-paste into a .py file and run.
454
500
* Relevant versions of *jsonmerge * and *jsonschema * - either release number
455
- on PyPi or git commit hash.
501
+ on PyPi or the git commit hash.
456
502
* Copy of the traceback, in case you are reporting an unhandled exception.
457
503
* Example of what you think should be the correct output, in case you are
458
504
reporting wrong result of a merge or schema generation.
@@ -494,6 +540,7 @@ THE SOFTWARE.
494
540
.. _Tox : https://tox.readthedocs.io/en/latest/
495
541
.. _GitHub issues : https://github.com/avian2/jsonmerge/issues
496
542
.. _GitHub pull requests : https://github.com/avian2/jsonmerge/pulls
543
+ .. _logging : https://docs.python.org/3/library/logging.html
497
544
498
545
..
499
546
vim: tw=75 ts=4 sw=4 expandtab softtabstop=4
0 commit comments