Skip to content

fix(common): streaming.secret requires SASL username with the mechanism - #1798

Merged
guimoreirar merged 2 commits into
mainfrom
fix/streaming-sasl-username
Jul 31, 2026
Merged

fix(common): streaming.secret requires SASL username with the mechanism#1798
guimoreirar merged 2 commits into
mainfrom
fix/streaming-sasl-username

Conversation

@guimoreirar

Copy link
Copy Markdown
Member

Addresses a fail-fast gap raised on midaz #1741 (Gandalf 5th review).

Problem

The SASL fail-fast (added earlier) only required STREAMING_SASL_PASSWORD. With a mechanism (e.g. SCRAM-SHA-512) and a password but no username, the render passed (Ledger and CRM), the ConfigMap emitted STREAMING_SASL_USERNAME: "", and the workload crashed at bootstrap — lib-streaming rejects a SASL mechanism without both credentials.

Fix

lerian-common.streaming.secret now accepts the resolved saslUsername (a ConfigMap value, resolved by the caller with configmap.STREAMING_SASL_USERNAME → global.streaming.saslUsername) and fails the render when a mechanism is set without it — same shape as the existing password check.

Validation

Scenario Result
mechanism + password, no username ❌ render fails (STREAMING_SASL_USERNAME)
mechanism + username, no password ❌ render fails (STREAMING_SASL_PASSWORD)
mechanism + both ✅ renders
no mechanism ✅ passes

helm lint passes. The midaz call sites pass saslUsername and negative assertions (username missing, Ledger + CRM) land with the re-pin in #1741.

The SASL fail-fast only checked STREAMING_SASL_PASSWORD; a mechanism configured with a
password but no username still rendered (STREAMING_SASL_USERNAME: "") and crashed at
boot, since lib-streaming rejects a SASL mechanism without BOTH credentials. Accept the
resolved saslUsername (ConfigMap value, configmap.STREAMING_SASL_USERNAME ->
global.streaming.saslUsername precedence) and fail the render when a mechanism is set
without it. Usage example updated to pass saslUsername.
@guimoreirar
guimoreirar requested a review from a team as a code owner July 31, 2026 21:08
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: de98afc3-cc1f-4b05-80d3-1ec57430f3b8

📥 Commits

Reviewing files that changed from the base of the PR and between 3e002ff and 2bbd552.

📒 Files selected for processing (1)
  • charts/lerian-common/templates/_streaming.tpl

📝 Walkthrough

Walkthrough

The streaming Secret helper now resolves SASL mechanism and username with ConfigMap-over-global precedence. It passes both values to the Secret helper and fails rendering when a configured mechanism has no username.

Changes

Streaming Secret credentials

Layer / File(s) Summary
SASL credential contract and validation
charts/lerian-common/templates/_streaming.tpl
The helper documents and passes saslUsername and saslMechanism. It validates that a username exists when a SASL mechanism is configured, before password validation or Secret emission.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/streaming-sasl-username

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/lerian-common/templates/_streaming.tpl`:
- Around line 113-122: Update the call to lerian-common.streaming.secret to
resolve saslMechanism and saslUsername using the same hasKey-based
ConfigMap-over-global precedence as lerian-common.streaming.env. Preserve
explicit empty ConfigMap values, then pass both resolved values so validation
handles ConfigMap-only settings correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 98f8d180-b50f-472f-9cf4-5156160647b8

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe41f4 and 3e002ff.

📒 Files selected for processing (1)
  • charts/lerian-common/templates/_streaming.tpl

Comment thread charts/lerian-common/templates/_streaming.tpl Outdated
…figmap precedence

The streaming.secret usage example read saslMechanism/saslUsername from global only, so a
copied consumer would bypass validation on a ConfigMap-only mechanism and hit a false
failure on a ConfigMap-only username. Show the configmap-over-global hasKey resolution
(matching streaming.env and the real midaz call sites).
@guimoreirar
guimoreirar merged commit 256dabd into main Jul 31, 2026
4 of 5 checks passed
@guimoreirar
guimoreirar deleted the fix/streaming-sasl-username branch July 31, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant