Skip to content

fix(cli): fatal on config parse error and use env for postgres log#6326

Merged
otavio merged 1 commit into
masterfrom
fix/cli-config-parsing-postgres-log-envs
May 14, 2026
Merged

fix(cli): fatal on config parse error and use env for postgres log#6326
otavio merged 1 commit into
masterfrom
fix/cli-config-parsing-postgres-log-envs

Conversation

@geovannewashington
Copy link
Copy Markdown
Member

What changed?

  • log.Error replaced with log.WithError().Fatal() on config parse
    failure to prevent execution continuing with a nil config.
  • Added POSTGRES_LOG_LEVEL and POSTGRES_LOG_VERBOSE to the config
    struct, replacing the hardcoded values in pgoptions.Log().
  • Added SHELLHUB_POSTGRES_LOG_LEVEL and SHELLHUB_POSTGRES_LOG_VERBOSE
    to .env and wired them through docker-compose.yml.

Why

Config parse errors were silently ignored, leading to a nil pointer
dereference on the next line. The postgres log options were also
hardcoded with no way to control them from the environment.

How to test

  1. Start the environment with ./bin/docker-compose up -d
  2. Set SHELLHUB_POSTGRES_LOG_VERBOSE=notabool in .env.override
  3. Run ./bin/cli user ls and confirm a fatal log is printed
  4. Revert the override and run ./bin/cli user create followed by
    ./bin/cli user ls to confirm normal operation
  5. Verify env vars with ./bin/docker-compose exec cli env | grep POSTGRES

Replace log.Error with log.WithError().Fatal() on ParseWithPrefix
failure to prevent execution continuing with a nil config.

Add PostgresLogLevel and PostgresLogVerbose fields to the config
struct so that pgoptions.Log() no longer uses hardcoded values.

Wire the new env vars in docker-compose.yml and .env following
the existing SHELLHUB_POSTGRES_* pattern.
@geovannewashington geovannewashington self-assigned this May 14, 2026
@geovannewashington geovannewashington requested a review from a team as a code owner May 14, 2026 17:21
@geovannewashington geovannewashington added go Pull requests that update Go code docker Pull requests that update Docker code labels May 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Claude finished @geovannewashington's task in 4m 50s —— View job


Code Review Complete

Reviewed 3 files across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is.

Summary of what was verified:

  • The log.Errorlog.WithError(err).Fatal fix correctly prevents nil-pointer dereference from continuing with a failed config parse.
  • New PostgresLogLevel / PostgresLogVerbose config fields are properly wired through .envdocker-compose.ymlcli/main.go, with safe defaults matching the env naming convention of existing fields.
  • The envs.ParseWithPrefix("CLI_") fallback via MultiLookuper correctly resolves the unprefixed env vars set in docker-compose.yml (consistent with how POSTGRES_HOST, POSTGRES_PORT, etc. are already handled).
  • logrus.ParseLevel validates the level string internally; invalid values propagate through pg.New and are caught by the existing fatal error check.
  • No cross-repo impact in cloud/ — the cloud repo has its own hardcoded pgoptions.Log("INFO", true) which is pre-existing and out of scope.

If you push additional changes and want a new review, tag @shellhub-io/admin and a team member can trigger it.

@otavio otavio merged commit 7fc70a8 into master May 14, 2026
21 of 22 checks passed
@otavio otavio deleted the fix/cli-config-parsing-postgres-log-envs branch May 14, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update Docker code go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants