Skip to content

Repository files navigation

Python & JavaScript Debugging Case Study — Reproduce, Fix, Test

CI

Python and JavaScript bugfix case study

This repository is a synthetic case study, not a client project. The bugs, requirements, code, and tests were created specifically for this public demonstration. No customer code or private data is included.

Proof first: See the before/after fix · Run the tests · View all demos · Request a scoped Python/JavaScript bug fix on Fiverr →

It demonstrates a compact debugging process for two common failures:

  • Python: an order discount is skipped exactly at the qualifying threshold.
  • JavaScript: a one-based page number is accidentally treated as zero-based.

Each case includes the buggy implementation, a minimal reproduction, a fixed implementation, regression tests, and a written root-cause analysis.

Repository layout

python_case/
  buggy.py             original threshold bug
  fixed.py             validated Decimal-based fix
javascript_case/
  buggy.js             original pagination bug
  fixed.js             corrected and validated pagination
tests/python/           Python reproduction and regression tests
tests/javascript/       JavaScript reproduction and regression tests
ROOT_CAUSE_REPORT.md    diagnosis, scope, before/after, and verification

Requirements

  • Python 3.10 or newer
  • Node.js 18 or newer for the JavaScript tests
  • No third-party packages

Run all tests

sh run_tests.sh

Or run the suites separately:

python3 -m unittest discover -s tests/python -v
node --test tests/javascript/*.test.js

Expected result:

Python: 5 tests passed
JavaScript: 4 tests passed, 0 failed

The reproduction assertions intentionally confirm the original bad behavior, while the regression assertions verify the corrected behavior. Therefore, a complete test run should pass.

Before and after

Case Input Buggy result Fixed result
Python discount boundary subtotal is exactly 100.00 100.00 90.00
JavaScript pagination page 1, size 3, items 1..7 [4, 5, 6] [1, 2, 3]

Minimal fixes:

- if subtotal > threshold:
+ if subtotal >= threshold:

- const start = page * pageSize;
+ const start = (page - 1) * pageSize;

See ROOT_CAUSE_REPORT.md for the full diagnosis, blast-radius analysis, fix rationale, and verification record.

Debugging approach shown here

  1. Reduce the report to the smallest deterministic failing input.
  2. Write a reproduction assertion before changing the implementation.
  3. Identify the violated contract and the exact faulty expression.
  4. Make a narrow fix and add input validation at the same boundary.
  5. Add regression coverage for the reported case and nearby edge cases.
  6. Document what changed, what did not change, and any remaining assumptions.

Need help with a real bug?

I handle scoped debugging for Python and JavaScript code. See the related Fiverr service:

Debug and fix Python or JavaScript code

Before ordering, please share the error message, minimal reproduction steps, relevant code, runtime/version, expected behavior, current behavior, and acceptance criteria. Do not send production credentials or secrets.

License

MIT — see LICENSE.

Releases

Packages

Contributors

Languages