Andrey - Get All Files#250
Conversation
Greptile SummaryThis PR adds a Issues found:
Checklist areas needing attention (score: 72/100):
Confidence Score: 4/5Safe to merge after addressing the silent error-swallowing in the service layer; the rest of the surface area is clean. One P1 issue exists: per-bucket errors are silently swallowed, causing getAllFiles to return HTTP 200 with missing data and no signal to the caller when buckets fail. This is a correctness issue on the changed path that should be resolved before merging. The remaining findings are P2 (hardcoded region, fragile test assertion, DB cleanup gap) and do not block merge on their own. packages/file-service/src/modules/file_bucket/file_bucket.service.ts — the inner catch block at line 182 needs to at minimum log errors before discarding them. Important Files Changed
|
| it('Successfully gets all files for a config', async () => { | ||
| const metadata = { | ||
| endpoint: baseURL, | ||
| region: region, | ||
| credentials: { | ||
| accessKeyId: accessKeyId as string, | ||
| secretAccessKey: secretAccessKey as string, | ||
| }, | ||
| }; | ||
|
|
||
| const client = new S3Client(metadata); | ||
| const command = new DeleteBucketCommand({ | ||
| Bucket: `get-all-files-bucket-${configId}-${configEnv}`, | ||
| }); | ||
|
|
||
| try { | ||
| await client.send(command); | ||
| } catch {} | ||
|
|
||
| await new Promise((resolve, reject) => { | ||
| bucketClient.registerBucket( | ||
| { | ||
| name: 'get-all-files-bucket', | ||
| configId, | ||
| configEnv, | ||
| fileProviderName: providerName, | ||
| }, | ||
| (err: any) => { | ||
| if (err) return reject(err); | ||
| resolve(0); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| const getAllFilesPromise = new Promise((resolve, reject) => { | ||
| bucketClient.getAllFiles( | ||
| { | ||
| configId, | ||
| configEnv, | ||
| }, | ||
| (err: any, response: any) => { | ||
| if (err) return reject(err); | ||
| expect(err).toBeNull(); | ||
| expect(response).toBeDefined(); | ||
| expect(response.files).toBeDefined(); | ||
| resolve(response); | ||
| }, | ||
| ); | ||
| }); | ||
| await getAllFilesPromise; | ||
|
|
||
| await client.send(command); |
There was a problem hiding this comment.
Test leaks a DB entry after the
getAllFiles happy-path test
registerBucket writes both to S3 and to the Juno DB. The cleanup at the end of the test calls client.send(command) which only deletes the S3 bucket; the corresponding DB row for get-all-files-bucket is never removed. The resetDb in beforeAll only runs once per test suite, so subsequent test runs (without a full reset) could see a stale row and get unexpected results.
Either call the service's removeBucket RPC after the assertions, or add a try/finally block so cleanup always runs even on test failure.
This reverts commit e16ff33.
Adds an endpoint to retrieve files from all S3 and Azure buckets for a config from the db. Includes E2E tests for both file-service and api-gateway.
Demo Video:
https://github.com/user-attachments/assets/d5cbcb8d-a2f9-4737-8d9c-c83b43248e2c