Fix backend integration test failures: Pinata mocking, error handling, timer leaks #195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Three issues prevented backend integration tests from passing: Pinata SDK threw "Invalid URL" errors on mock blob IDs,
/decrypt-ansreturned 400 instead of 500 for processing errors, and TTL cleanup interval created Jest open handles.Changes
backend/src/services/pinata.js
NODE_ENV === 'test'or blob ID starts withmock-backend/src/server.js
setIntervalwithNODE_ENV !== 'test'check to prevent timer leaks/decrypt-ansin try/catch to return 500 on failures (matches/decrypt-cluespattern)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
block-indexer.litgateway.com/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/jest-worker/build/workers/processChild.js(dns block)/usr/local/bin/node node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/.bin/jest --testPathPattern=integration --detectOpenHandles(dns block)eth.drpc.org/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/jest-worker/build/workers/processChild.js(dns block)/usr/local/bin/node node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/.bin/jest --testPathPattern=integration --detectOpenHandles(dns block)eth.llamarpc.com/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/jest-worker/build/workers/processChild.js(dns block)/usr/local/bin/node node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/.bin/jest --testPathPattern=integration --detectOpenHandles(dns block)ethereum-rpc.publicnode.com/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/jest-worker/build/workers/processChild.js(dns block)/usr/local/bin/node node /home/REDACTED/work/Khoj/Khoj/backend/node_modules/.bin/jest --testPathPattern=integration --detectOpenHandles(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Summary
Create a new pull request which applies three targeted fixes so the backend integration tests stop failing (job 57358500786). The PR should branch off feature/integration-testing (PR #158 branch) and contain the concrete code changes described below.
Root causes to fix
Files to change
Patch examples (apply at the same locations in server.js):
1.a Guard TTL cleanup interval (replace current setInterval call)
1.b Replace /decrypt-ans handler