Let me share a pattern from years of mentoring: when someone says "this function is broken", it is correct about 20% of the time. The rest, the function is faithfully doing what it was asked, and the input, the config, or the assumption is wrong.
My standard questions, in order:
- What did you expect to happen? Write it down in one sentence.
- What actually happened? Not "it doesn't work", the actual output.
- What is the smallest input that shows it?
- What changed since the last time it worked?
- Have you checked that the code you are running is the code you are reading? (Stale build, wrong environment, cached container image. You would be amazed.)
I will not give you the answer. I will keep asking until you say "oh". Everyone says "oh". Usually around question 3.
What is the most embarrassing "oh" you have had?