You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
This PR fixes a bug where the CLICKHOUSE_AUDIT_LOG_INSERT_SETTINGS environment variable defaults were not being applied correctly. Previously, when using Zod's .default() with a .transform(), the default value wasn't used when the environment variable was empty or unset, causing the transformation to return incorrect default values.
Key Changes:
Extracted DEFAULT_CLICKHOUSE_AUDIT_LOG_INSERT_SETTINGS as a constant at module level
Changed .default() to use JSON.stringify() of the constant, ensuring the default is applied after transformation
Changed ClickHouse audit log insert to use auditLog.createdAt from PostgreSQL instead of new Date(), ensuring timestamp consistency between both databases for easier deduplication
Added explanatory comments for both id and createdAt synchronization
Technical Context:
When Zod's .transform() is applied before .default(), the transformation runs first even for undefined/empty values, so the inline object literal default was never used. By extracting to a constant and using JSON.stringify() in the default, the chain now works correctly: empty values are caught by the transformation, which returns the constant, and the stringified constant serves as the actual default value.
Confidence Score: 5/5
This PR is safe to merge with minimal risk
The changes are well-focused bug fixes that improve data consistency. The refactoring extracts defaults to a constant (better maintainability), and using auditLog.createdAt from PostgreSQL ensures timestamps match between databases. Both changes are backwards-compatible and don't introduce breaking changes.
No files require special attention
Important Files Changed
Filename
Overview
backend/src/lib/config/env.ts
Extracts ClickHouse default settings to constant, fixing bug where .default() didn't apply default values during transformation
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
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.
…nsert settings issue
Context
https://linear.app/infisical/issue/ENG-4569/update-backend-to-make-audit-query-send-to-clickhouse-based-on
Steps to verify the change
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).