Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions apps/gateway/src/services/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import fs from "fs";
📦 Load Proto
========================================= */

const protoPath = path.resolve(
__dirname,
"../../../../libs/proto/device.proto"
);
const protoPath = fs.existsSync("/app/libs/proto/device.proto")
? "/app/libs/proto/device.proto"
: path.resolve(__dirname, "../../libs/proto/device.proto");
Comment on lines +11 to +13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fallback path incorrect for local development.

The primary absolute path /app/libs/proto/device.proto correctly resolves inside the Docker container. However, the fallback ../../libs/proto/device.proto assumes a flat structure that doesn't match local development.

When running locally from apps/gateway/dist/services/device.js, ../../libs/ resolves to apps/gateway/libs/, but the proto file lives at the repo root (libs/proto/device.proto), requiring ../../../../libs/proto/device.proto.

If local dev support isn't needed, consider adding a comment. Otherwise:

🔧 Suggested fix to support both environments
-const protoPath = fs.existsSync("/app/libs/proto/device.proto")
-  ? "/app/libs/proto/device.proto"
-  : path.resolve(__dirname, "../../libs/proto/device.proto");
+// Docker: proto at /app/libs/proto/device.proto
+// Local:  proto at repo root, 4 levels up from apps/gateway/dist/services/
+const protoPath = fs.existsSync("/app/libs/proto/device.proto")
+  ? "/app/libs/proto/device.proto"
+  : path.resolve(__dirname, "../../../../libs/proto/device.proto");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const protoPath = fs.existsSync("/app/libs/proto/device.proto")
? "/app/libs/proto/device.proto"
: path.resolve(__dirname, "../../libs/proto/device.proto");
// Docker: proto at /app/libs/proto/device.proto
// Local: proto at repo root, 4 levels up from apps/gateway/dist/services/
const protoPath = fs.existsSync("/app/libs/proto/device.proto")
? "/app/libs/proto/device.proto"
: path.resolve(__dirname, "../../../../libs/proto/device.proto");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/gateway/src/services/device.ts` around lines 11 - 13, The fallback path
for protoPath is wrong for local dev: update the fallback in the protoPath
expression (the ternary using fs.existsSync and __dirname) to point to the
repo-root location (e.g., use path.resolve(__dirname,
"../../../../libs/proto/device.proto") or path.resolve(__dirname, "../../../..",
"libs/proto/device.proto")) so when running apps/gateway/dist/services/device.js
it resolves to libs/proto/device.proto; alternatively, if local development
support is intentionally not required, add a clarifying comment above the
protoPath declaration noting the code only supports the container absolute path.


const packageDefinition = protoLoader.loadSync(protoPath, {
keepCase: true,
Expand Down
Loading