Skip to content

allow for docker registry password to be a file #2419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

julienvanbeveren
Copy link

No description provided.

Copy link

changeset-bot bot commented Aug 19, 2025

🦋 Changeset detected

Latest commit: b80c015

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
trigger.dev Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/zod-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

  • Adds a changeset file for a patch release note: “Allow for DOCKER_REGISTRY_PASSWORD to be a file path.”
  • Updates apps/supervisor/src/workloadManager/docker.ts to support DOCKER_REGISTRY_PASSWORD as a file via file://.
  • Introduces getDockerPassword() to read and trim password from the referenced file or return the env value.
  • Imports readFileSync from fs for file reads; logs debug on path and errors on failure.
  • Replaces stored auth property with an auth() method that constructs Docker auth config using getDockerPassword().
  • Adjusts image creation calls to use this.auth(); adds constructor logs about credential presence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
apps/supervisor/src/workloadManager/docker.ts (3)

11-11: Avoid synchronous disk I/O on the hot path (optional)

Using readFileSync will block the event loop. Given this runs in the supervisor, impact is likely small, but consider either caching the password at startup or switching to async fs.promises.readFile with an async auth path.


280-307: Optional: cache password after first resolution

If create() is called frequently, re-reading the same file each time is unnecessary. You can memoize the computed password (including the env string path case) to avoid repeated I/O.


51-61: Add basic tests for password resolution paths

Tests to cover: plain env value, file:// happy path, file:// missing file (should log and skip auth), trimming behavior. I can scaffold these if helpful.

Also applies to: 280-307

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 32e3fab and b80c015.

📒 Files selected for processing (2)
  • .changeset/red-moose-design.md (1 hunks)
  • apps/supervisor/src/workloadManager/docker.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • apps/supervisor/src/workloadManager/docker.ts
🧬 Code Graph Analysis (1)
apps/supervisor/src/workloadManager/docker.ts (1)
apps/supervisor/src/env.ts (1)
  • env (105-105)
🔇 Additional comments (4)
.changeset/red-moose-design.md (1)

1-6: Changelog entry LGTM

Clear and scoped. Patch level is appropriate for this behavior change.

apps/supervisor/src/workloadManager/docker.ts (3)

41-49: Credential presence logging LGTM

Good clarity on whether registry auth will be attempted.


169-175: Image pull refactor LGTM (uses auth() method)

Swapping to this.auth() keeps behavior consistent while computing auth lazily. Once auth() is made safe against throws, this will be robust.


51-61: No lingering this.auth property accesses detected

  • Verified with rg -n -C2 -g '!**/dist/**' -P '\bthis\.auth\b(?!\s*\()' and found no matches.

All call sites correctly invoke this.auth().

Comment on lines +51 to 61
private auth(): Docker.AuthConfig | undefined {
if (env.DOCKER_REGISTRY_USERNAME && env.DOCKER_REGISTRY_PASSWORD && env.DOCKER_REGISTRY_URL) {
return {
username: env.DOCKER_REGISTRY_USERNAME,
password: env.DOCKER_REGISTRY_PASSWORD,
password: getDockerPassword(),
serveraddress: env.DOCKER_REGISTRY_URL,
};
} else {
this.logger.warn("🐋 No Docker registry credentials provided, skipping auth");
}

return undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Synchronous throw from getDockerPassword can crash create() before tryCatch; handle errors inside auth()

this.auth() calls getDockerPassword(), which may throw. Because arguments are evaluated before awaiting tryCatch(this.docker.createImage(...)), any synchronous throw here will bypass tryCatch and bubble out of create(), potentially crashing the supervisor. Wrap resolution and guard against empty/undefined passwords.

Apply this diff:

   private auth(): Docker.AuthConfig | undefined {
-    if (env.DOCKER_REGISTRY_USERNAME && env.DOCKER_REGISTRY_PASSWORD && env.DOCKER_REGISTRY_URL) {
-      return {
-        username: env.DOCKER_REGISTRY_USERNAME,
-        password: getDockerPassword(),
-        serveraddress: env.DOCKER_REGISTRY_URL,
-      };
-    }
-
-    return undefined;
+    if (!(env.DOCKER_REGISTRY_USERNAME && env.DOCKER_REGISTRY_PASSWORD && env.DOCKER_REGISTRY_URL)) {
+      return undefined;
+    }
+
+    try {
+      const password = getDockerPassword();
+      if (!password) {
+        this.logger.warn("🐋 Docker registry password resolved to empty/undefined, skipping auth", {
+          username: env.DOCKER_REGISTRY_USERNAME,
+          url: env.DOCKER_REGISTRY_URL,
+        });
+        return undefined;
+      }
+
+      return {
+        username: env.DOCKER_REGISTRY_USERNAME,
+        password,
+        serveraddress: env.DOCKER_REGISTRY_URL,
+      };
+    } catch (error) {
+      this.logger.error("🐋 Failed to resolve Docker registry password, skipping auth", { error });
+      return undefined;
+    }
   }
📝 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
private auth(): Docker.AuthConfig | undefined {
if (env.DOCKER_REGISTRY_USERNAME && env.DOCKER_REGISTRY_PASSWORD && env.DOCKER_REGISTRY_URL) {
return {
username: env.DOCKER_REGISTRY_USERNAME,
password: env.DOCKER_REGISTRY_PASSWORD,
password: getDockerPassword(),
serveraddress: env.DOCKER_REGISTRY_URL,
};
} else {
this.logger.warn("🐋 No Docker registry credentials provided, skipping auth");
}
return undefined;
}
private auth(): Docker.AuthConfig | undefined {
if (!(env.DOCKER_REGISTRY_USERNAME && env.DOCKER_REGISTRY_PASSWORD && env.DOCKER_REGISTRY_URL)) {
return undefined;
}
try {
const password = getDockerPassword();
if (!password) {
this.logger.warn("🐋 Docker registry password resolved to empty/undefined, skipping auth", {
username: env.DOCKER_REGISTRY_USERNAME,
url: env.DOCKER_REGISTRY_URL,
});
return undefined;
}
return {
username: env.DOCKER_REGISTRY_USERNAME,
password,
serveraddress: env.DOCKER_REGISTRY_URL,
};
} catch (error) {
this.logger.error("🐋 Failed to resolve Docker registry password, skipping auth", { error });
return undefined;
}
}
🤖 Prompt for AI Agents
In apps/supervisor/src/workloadManager/docker.ts around lines 51 to 61, auth()
currently calls getDockerPassword() directly which can synchronously throw and
escape the outer tryCatch in create(); wrap the getDockerPassword() call in an
internal try/catch so auth() never throws (catch errors and return undefined or
omit the password field), and additionally guard against empty/undefined
password values (if password is falsy return undefined or build the auth object
without the password) so create() cannot be crashed by a synchronous exception
from getDockerPassword().

Comment on lines +280 to +307
function getDockerPassword(): string | undefined {
if (!env.DOCKER_REGISTRY_PASSWORD) {
return undefined
}
if (!env.DOCKER_REGISTRY_PASSWORD.startsWith("file://")) {
return env.DOCKER_REGISTRY_PASSWORD;
}

const passwordPath = env.DOCKER_REGISTRY_PASSWORD.replace("file://", "");

console.debug(
JSON.stringify({
message: "🔑 Reading docker password from file",
passwordPath,
})
);

try {
const password = readFileSync(passwordPath, "utf8").trim();
return password;
} catch (error) {
console.error(`Failed to read docker password from file: ${passwordPath}`, error);
throw new Error(
`Unable to read docker password from file: ${error instanceof Error ? error.message : "Unknown error"
}`
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Don’t throw on password file read failure; use structured logging and return undefined

Throwing here can crash the call site (see auth() comment). Prefer logging and returning undefined so the caller can skip auth. Also, use the project’s structured logger instead of console.* and fix minor style nits.

Apply this diff:

 function getDockerPassword(): string | undefined {
   if (!env.DOCKER_REGISTRY_PASSWORD) {
-    return undefined
+    return undefined;
   }
   if (!env.DOCKER_REGISTRY_PASSWORD.startsWith("file://")) {
     return env.DOCKER_REGISTRY_PASSWORD;
   }
 
   const passwordPath = env.DOCKER_REGISTRY_PASSWORD.replace("file://", "");
 
-  console.debug(
-    JSON.stringify({
-      message: "🔑 Reading docker password from file",
-      passwordPath,
-    })
-  );
+  moduleLogger.debug("🔑 Reading docker password from file", { passwordPath });
 
   try {
     const password = readFileSync(passwordPath, "utf8").trim();
     return password;
   } catch (error) {
-    console.error(`Failed to read docker password from file: ${passwordPath}`, error);
-    throw new Error(
-      `Unable to read docker password from file: ${error instanceof Error ? error.message : "Unknown error"
-      }`
-    );
+    moduleLogger.error("Failed to read docker password from file", {
+      passwordPath,
+      error,
+    });
+    return undefined;
   }
 }

Add this module-level logger once near the top of the file (outside the selected range):

// Module-level logger for helpers outside the class
const moduleLogger = new SimpleStructuredLogger("docker-workload-manager");
🤖 Prompt for AI Agents
In apps/supervisor/src/workloadManager/docker.ts around lines 280 to 307, the
helper currently uses console.debug/console.error and throws on failing to read
a password file; change it to use the project’s module-level structured logger
and return undefined on failure instead of throwing so callers can skip auth.
Add the suggested moduleLogger declaration once near the top of the file
(outside this range): const moduleLogger = new
SimpleStructuredLogger("docker-workload-manager"); then replace console.debug
with moduleLogger.debug(...) including the same message and passwordPath, and in
the catch block call moduleLogger.warn or moduleLogger.error with a structured
object { message: "Failed to read docker password from file", passwordPath,
error: error instanceof Error ? error.message : String(error) } and return
undefined instead of throwing; keep the same behavior for non-file passwords and
undefined env values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant