ducktors / turborepo-remote-cache

Open source implementation of the Turborepo custom remote cache server.
https://ducktors.github.io/turborepo-remote-cache/
MIT License
1.03k stars 95 forks source link

DIfferent behavior between docker image and npm package (`slug` not recognized as a team ID) #39

Closed vadimgusev-codefresh closed 2 years ago

vadimgusev-codefresh commented 2 years ago

Hi, I'm trying out very basic case with local filesystem as a storage backend.

I'm running turbo like this:

turbo run build --api="http://localhost:3000" --token=mytoken --team=myteam --remote-only

In case of docker image everything works as expected:

docker run -it --rm -p 3000:3000 -e STORAGE_PROVIDER=local -e TURBO_TOKEN=mytoken -e LOG_LEVEL=debug fox1t/turborepo-remote-cache:1.5.1
...
{"severity":"INFO","level":30,"time":1661781474850,"pid":8,"hostname":"7ae9741d9db3","reqId":"OpxpJZ7SSmyC3DTj5cV1tw-49","req":{"method":"PUT","url":"/v8/artifacts/1604679dd3f91bfc?slug=myteam","hostname":"localhost:3000","remoteAddress":"172.17.0.1","remotePort":61292},"message":"incoming request"}
{"severity":"INFO","level":30,"time":1661781474859,"pid":8,"hostname":"7ae9741d9db3","reqId":"OpxpJZ7SSmyC3DTj5cV1tw-49","res":{"statusCode":200},"responseTime":9.032999999821186,"message":"request completed"}

But when I run npx equivalent I get the following error:

STORAGE_PROVIDER=local TURBO_TOKEN=mytoken LOG_LEVEL=debug npx turborepo-remote-cache@1.5.1
...
{"severity":"INFO","level":30,"time":1661781704349,"pid":72243,"hostname":"Vadims-MacBook-Pro.local","reqId":"3oYQdZzrRU6eocU3CQtKzg-4","req":{"method":"GET","url":"/v8/artifacts/834351818444d6ba?slug=myteam","hostname":"localhost:3000","remoteAddress":"127.0.0.1","remotePort":64930},"message":"incoming request"}
{"severity":"WARNING","level":40,"time":1661781704349,"pid":72243,"hostname":"Vadims-MacBook-Pro.local","reqId":"3oYQdZzrRU6eocU3CQtKzg-4","validation":[{"keyword":"required","dataPath":"","schemaPath":"#/required","params":{"missingProperty":"teamId"},"message":"should have required property 'teamId'"}],"validationContext":"querystring","stack":"Error: querystring should have required property 'teamId'\n    at defaultSchemaErrorFormatter (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/context.js:40:10)\n    at wrapValidationError (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/validation.js:105:17)\n    at validate (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/validation.js:90:12)\n    at preValidationCallback (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/handleRequest.js:89:18)\n    at handler (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/handleRequest.js:72:7)\n    at handleRequest (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/handleRequest.js:20:5)\n    at runPreParsing (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/route.js:451:5)\n    at next (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/hooks.js:158:7)\n    at handleResolve (/Users/vadim/.npm/_npx/dd8a09686e5b1d7e/node_modules/fastify/lib/hooks.js:175:5)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)","type":"Error","message":"querystring should have required property 'teamId'"}
{"severity":"INFO","level":30,"time":1661781704350,"pid":72243,"hostname":"Vadims-MacBook-Pro.local","reqId":"3oYQdZzrRU6eocU3CQtKzg-4","res":{"statusCode":400},"responseTime":0.24070799350738525,"message":"request completed"}

Seems like whatever version is published on npm doesn't recognize slug as team ID.

vadimgusev-codefresh commented 2 years ago

Turns out npm package doesn't contain this commit: https://github.com/fox1t/turborepo-remote-cache/commit/4ceb67f647a4e8754027a9bc7bb5620c67c9c596

fox1t commented 2 years ago

This is so unfortunate. Which version are you downloading from npm?

vadimgusev-codefresh commented 2 years ago

@fox1t from my log above: npx turborepo-remote-cache@1.5.1

fox1t commented 2 years ago

Fixed in v1.6.0