Skip to content

feat(workflow-executor): optional database TLS via DATABASE_SSL#1685

Merged
PMerlet merged 3 commits into
mainfrom
feat/workflow-executor-database-ssl
Jun 19, 2026
Merged

feat(workflow-executor): optional database TLS via DATABASE_SSL#1685
PMerlet merged 3 commits into
mainfrom
feat/workflow-executor-database-ssl

Conversation

@PMerlet

@PMerlet PMerlet commented Jun 19, 2026

Copy link
Copy Markdown
Member

Problem

Managed databases (AWS RDS, etc.) commonly require TLS. The executor CLI only passed the connection URI to Sequelize with no SSL option, so against such a database the connection is rejected at startup:

no pg_hba.conf entry for host "…", user "…", database "…", no encryption

runStore.init() (migration) throws → the process exits → the service never becomes healthy. Hit while deploying the executor as a Beanstalk service against the staging RDS (which enforces SSL).

Fix

Add a DATABASE_SSL env var. When enabled, the database connection uses:

dialectOptions: { ssl: { require: true, rejectUnauthorized: false } }

i.e. encrypt without verifying the server certificate — the same setup the agent's server uses for staging/production RDS, and the standard approach for RDS without bundling the CA. Defaults off, so existing non-TLS deployments are unchanged.

Robust parsing (QA hardening)

DATABASE_SSL is parsed leniently — true / 1 / yes / on (case-insensitive) enable it, false / 0 / no / off / unset disable it — and an unrecognized value throws ConfigurationError rather than silently disabling TLS (the same footgun we just removed for LOG_LEVEL).

Observability

The resolved database TLS state is logged at startup (databaseSsl in the "Workflow executor starting" line), so operators can confirm whether the connection is encrypted.

Tests

cli.test.ts83 passing, and cli-core.ts at 100% statements / lines / functions (all changed lines covered):

  • DATABASE_SSL truthy variants (true/TRUE/True/1/yes/on) → enabled.
  • Falsy variants (false/0/no/off/'') → disabled; unset → disabled.
  • Unrecognized value → throws ConfigurationError.
  • runCli with SSL on → buildDatabase receives database.dialectOptions.ssl = { require: true, rejectUnauthorized: false }; with SSL off → database stays { uri }.
  • logStartup reports databaseSsl in database mode.

Documented in the README and --help.

Known limitation (intentional)

rejectUnauthorized: false is the only TLS mode offered — it encrypts but does not verify the server certificate (MITM exposure). This matches the agent's server setup and is the practical choice for RDS, but there is no verify-full / custom-CA option yet. Worth a follow-up for stricter TLS policies. End-to-end TLS is verified at deploy time (no SSL-capable DB in this package's CI; the tests assert wiring).

🤖 Generated with Claude Code

PMerlet and others added 2 commits June 19, 2026 14:22
Managed databases (RDS, etc.) commonly require TLS, but the CLI only passed the
connection URI to Sequelize with no SSL option, so the executor was rejected
with "no pg_hba.conf entry ... no encryption" and crashed at startup.

Add DATABASE_SSL=true to connect over TLS using
`dialectOptions: { ssl: { require: true, rejectUnauthorized: false } }` —
encrypt without verifying the server certificate, mirroring the agent's server
setup. Defaults off, so existing non-TLS setups are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@qltysh

qltysh Bot commented Jun 19, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/cli-core.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

QA hardening of the DATABASE_SSL flag:
- Parse it leniently (true/1/yes/on, case-insensitive) and throw
  ConfigurationError on an unrecognized value, instead of silently treating
  anything but "true" as disabled — same footgun we just removed for LOG_LEVEL.
- Log the resolved database TLS state at startup so operators can confirm
  whether the connection is encrypted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PMerlet PMerlet merged commit 91870c7 into main Jun 19, 2026
31 checks passed
@PMerlet PMerlet deleted the feat/workflow-executor-database-ssl branch June 19, 2026 12:38
forest-bot added a commit that referenced this pull request Jun 19, 2026
# @forestadmin/workflow-executor [1.6.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/workflow-executor@1.5.1...@forestadmin/workflow-executor@1.6.0) (2026-06-19)

### Features

* **workflow-executor:** optional database TLS via DATABASE_SSL ([#1685](#1685)) ([91870c7](91870c7))
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