Make NATS credentials optional for the nats publisher - #34
Merged
Merged
Conversation
tamalsaha
force-pushed
the
nats-optional-credentials
branch
from
September 13, 2026 12:21
82f929c to
bb2609c
Compare
NatsCredPath was required whenever publisher.type is nats (validate:"required_if=Type nats"), and factoryPublisher always passed it to nats.UserCredentials(...) even when empty -- so pointing pgoutbox at a NATS deployment with no auth configured at all (the common case for a local or trusted-network deployment) failed both config validation and the connection attempt itself, with no way to opt out. Drop the required_if tag and only apply nats.UserCredentials when NatsCredPath is actually set; connect without it otherwise. A NATS server that does require auth is unaffected: setting NatsCredPath still works exactly as before. Signed-off-by: Tamal Saha <tamal@appscode.com>
tamalsaha
force-pushed
the
nats-optional-credentials
branch
from
September 13, 2026 12:26
bb2609c to
8c3e2ae
Compare
Imtiaz246
approved these changes
Sep 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
publisher.natsCredPathwas required wheneverpublisher.typeisnats(
validate:"required_if=Type nats"), andfactoryPublisheralways passedit straight to
nats.UserCredentials(...), even when empty. Pointingpgoutbox at a NATS deployment with no auth configured at all (a local dev
instance, or a trusted in-cluster NATS with no auth turned on) failed both
config validation and the connection attempt itself, with no way to opt
out short of a local patch.
Fix
apis/config.go: drop therequired_if=Type natsvalidation tag onNatsCredPath, documented as optional.cmd/pgoutbox/init.go: only passnats.UserCredentials(...)whenNatsCredPathis actually set; connect without it otherwise.apis/config_test.go: updated the existing "missing NatsCredPath" caseto assert success (credential-less mode) instead of the old
required_ifvalidation error; the existing "with NatsCredPath -success" case is unchanged, so a NATS server that does require auth is
unaffected.
Verification
gofmt -landgofumpt -lclean,golangci-lint runclean,go build ./.../go vet ./...clean,go test ./...passes.go mod tidyleaves
go.mod/go.sum/vendor/untouched (no new dependency).Signed-off-by: Tamal Saha tamal@appscode.com