I spent 3 hours debugging. Then I found the print statement.
I spent 3 hours debugging. Then I found the print statement. Wasted Wednesday afternoon tracking down why my API kept returning 500 errors. Turned out someone left a debug print in production that ...

Source: DEV Community
I spent 3 hours debugging. Then I found the print statement. Wasted Wednesday afternoon tracking down why my API kept returning 500 errors. Turned out someone left a debug print in production that broke the JSON response. What happened API endpoint worked fine locally. Deployed to staging, started getting 500s. Error logs said "invalid JSON" but the response looked clean in Postman. Checked database queries. Fine. Environment variables all set. Request headers valid. Network logs looked normal. Three hours of this. Found it by accident Piped the raw response to a file: curl -s https://api.example.com/users | cat -A Saw this: DEBUG: Query took 0.34s$ {"users": [...]}$ Someone left a print statement in the database wrapper. JSON parser choked on the text before the actual JSON. # The culprit def fetch_users(): start = time.time() result = db.query("SELECT * FROM users") print(f"DEBUG: Query took {time.time() - start:.2f}s") # ← This return result Deleted the print statement. Deployed. AP