Skip to content

feat(api-service): update logger level runtime#9902

Open
djabarovgeorge wants to merge 10 commits intonextfrom
update-logger-level-runtime
Open

feat(api-service): update logger level runtime#9902
djabarovgeorge wants to merge 10 commits intonextfrom
update-logger-level-runtime

Conversation

@djabarovgeorge
Copy link
Contributor

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

Hey there and thank you for opening this pull request! 👋

We require pull request titles to follow specific formatting rules and it looks like your proposed title needs to be adjusted.

Your PR title is: feat(api-service): update logger level runtime

Requirements:

  1. Follow the Conventional Commits specification
  2. As a team member, include Linear ticket ID at the end: fixes TICKET-ID or include it in your branch name

Expected format: feat(scope): Add fancy new feature fixes NOV-123

Details:

PR title must end with 'fixes TICKET-ID' (e.g., 'fixes NOV-123') or include ticket ID in branch name

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit da59dfa
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/697763c4429f0400089e6a41
😎 Deploy Preview https://deploy-preview-9902.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a new LogLevelService that reads the log level from the feature flag LOG_LEVEL_STR with fallbacks to LOG_LEVEL / LOGGING_LEVEL, validates against exported loggingLevelArr/loggingLevelSet, and polls for changes at runtime. Exposes the service via multiple SharedModules (api, webhook, worker, ws). Publishes logging constants and a log-level service barrel in application-generic. Updates feature flag types (adds LOG_LEVEL_STR, renames CF_SCHEDULER_MODE to CF_SCHEDULER_MODE_STR, moves two flags), adjusts env validators to validate boolean, numeric, and specific string flags, and switches scheduler usage to CF_SCHEDULER_MODE_STR.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description contains only template placeholders with no actual implementation details, context, or explanation of the changes made. Provide meaningful description explaining what changed, why it was needed, and any relevant context or links (Linear tickets, discussions, etc.).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: implementing runtime logger level updates across the application modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/novuhq/novu@9902
npm i https://pkg.pr.new/novuhq/novu/@novu/providers@9902
npm i https://pkg.pr.new/novuhq/novu/@novu/shared@9902

commit: da59dfa

…ndling

- Updated env.validators.ts to categorize feature flags into Boolean, Numeric, and String types.
- Refactored log-level.service.ts to use new feature flag keys for LOG_LEVEL and added a default polling interval.
- Adjusted standard-queue.service.ts to reference the updated CF_SCHEDULER_MODE_STR flag.
- Added new feature flag keys IS_ANALYTICS_PAGE_ENABLED and IS_LEGACY_SELECTOR_BUTTON_VISIBLE in feature-flags.ts.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

LaunchDarkly flag references

🔍 4 flags added or modified

Name Key Aliases found Info
CF_SCHEDULER_MODE_STR CF_SCHEDULER_MODE_STR
IS_ANALYTICS_PAGE_ENABLED IS_ANALYTICS_PAGE_ENABLED
IS_LEGACY_SELECTOR_BUTTON_VISIBLE IS_LEGACY_SELECTOR_BUTTON_VISIBLE
LOG_LEVEL_STR LOG_LEVEL_STR

❌ 1 flag removed

Name Key Aliases found Info
CF_SCHEDULER_MODE CF_SCHEDULER_MODE ✅ all references removed

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/shared/src/types/feature-flags.ts (1)

96-104: MAX_ENVIRONMENT_COUNT doesn't follow the NumericFlagKey naming convention.

The NumericFlagKey type (line 6) expects numeric flags to end with _NUMBER, but MAX_ENVIRONMENT_COUNT does not. This inconsistency means it won't be picked up by the numeric validator filter in env.validators.ts and may fail type checking with testFlagEnumValidity.

💡 Suggested fix to follow the naming convention
-  MAX_ENVIRONMENT_COUNT = 'MAX_ENVIRONMENT_COUNT',
+  MAX_ENVIRONMENT_COUNT_NUMBER = 'MAX_ENVIRONMENT_COUNT_NUMBER',
🤖 Fix all issues with AI agents
In `@apps/api/src/config/env.validators.ts`:
- Around line 85-92: The numeric validator block is skipping
MAX_ENVIRONMENT_COUNT because the filter uses key.endsWith('_NUMBER'); update
the filter or add an explicit inclusion so MAX_ENVIRONMENT_COUNT gets a numeric
validator: modify the .filter(...) used on Object.keys(FeatureFlagsKeysEnum) to
also accept key === 'MAX_ENVIRONMENT_COUNT' (or a more general pattern that
matches this enum name), ensuring the reduce still assigns acc[key] = num({
default: undefined }) for that key; reference FeatureFlagsKeysEnum, the current
.filter(key => key.endsWith('_NUMBER')), and the reducer that sets acc[key] =
num(...) when making the change.

In `@libs/application-generic/src/services/log-level/log-level.service.ts`:
- Around line 95-101: Replace the fragile any-casts in setLogLevel by using the
public NestJS PinoLogger root API: instead of touching (this.logger as
any).pinoLogger or .logger, set PinoLogger.root.level directly (import or
reference PinoLogger and assign its static/root level) to update the log level;
update the setLogLevel method to read the incoming level and set
PinoLogger.root.level = level, removing the any casts and internal property
checks on this.logger.

In `@packages/shared/src/types/feature-flags.ts`:
- Around line 89-90: The enum value IS_LEGACY_SELECTOR_BUTTON_VISIBLE violates
the BooleanFlagKey naming convention; rename the enum member to follow the
_ENABLED/_DISABLED pattern (e.g., IS_LEGACY_SELECTOR_BUTTON_ENABLED) and update
its string value to match, then update all references/usages (imports, tests,
feature-flag lookups, and any persisted keys) to the new symbol; ensure
BooleanFlagKey type usage and any switch/conditionals that check
IS_LEGACY_SELECTOR_BUTTON_VISIBLE are updated to the new name so compilation and
runtime behavior remain correct.
🧹 Nitpick comments (2)
libs/application-generic/src/services/log-level/log-level.service.ts (2)

67-85: Clarify the string 'undefined' check.

Line 75 checks both truthiness and explicitly compares against the string 'undefined'. If the feature flag service can return a literal string 'undefined', consider adding a comment to document this behavior. Otherwise, the truthy check alone should suffice.

💡 Suggested simplification (if string 'undefined' is not expected)
-      if (flagValue && flagValue !== 'undefined') {
+      if (flagValue) {
         return flagValue;
       }

60-64: Consider handling setLogLevel failures.

If setLogLevel throws an exception (e.g., due to unexpected Pino internals), the currentLogLevel field won't be updated, but the exception will propagate and potentially stop the polling. Consider wrapping setLogLevel in a try-catch to maintain resilience.

💡 Suggested defensive handling
     if (newLogLevel !== this.currentLogLevel) {
+      try {
         this.setLogLevel(newLogLevel);
         Logger.log(`Log level changed from "${this.currentLogLevel}" to "${newLogLevel}"`, LOG_CONTEXT);
         this.currentLogLevel = newLogLevel;
+      } catch (error) {
+        Logger.warn(`Failed to set log level to "${newLogLevel}": ${(error as Error).message}`, LOG_CONTEXT);
+      }
     }

Comment on lines +85 to +92
// Feature Flags - Numeric (end with _NUMBER)
...Object.keys(FeatureFlagsKeysEnum)
.filter((key) => key.endsWith('_NUMBER'))
.reduce<Record<string, ValidatorSpec<number | undefined>>>((acc, key) => {
acc[key] = num({ default: undefined });

return acc;
}, {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the MAX_ENVIRONMENT_COUNT definition and any usages
rg -n "MAX_ENVIRONMENT_COUNT" --type=ts -C2

Repository: novuhq/novu

Length of output: 1239


🏁 Script executed:

#!/bin/bash
# Check the env.validators.ts file to see how feature flags are validated
cat -n apps/api/src/config/env.validators.ts | sed -n '70,100p'

Repository: novuhq/novu

Length of output: 1380


🏁 Script executed:

#!/bin/bash
# Check if MAX_ENVIRONMENT_COUNT is explicitly validated anywhere in env.validators.ts
rg -n "MAX_ENVIRONMENT_COUNT" apps/api/src/config/env.validators.ts

Repository: novuhq/novu

Length of output: 37


🏁 Script executed:

#!/bin/bash
# Get all keys in FeatureFlagsKeysEnum to see the complete list
cat -n packages/shared/src/types/feature-flags.ts | grep -A 30 "enum FeatureFlagsKeysEnum"

Repository: novuhq/novu

Length of output: 2226


🏁 Script executed:

#!/bin/bash
# Get the rest of FeatureFlagsKeysEnum to see numeric flags and MAX_ENVIRONMENT_COUNT
cat -n packages/shared/src/types/feature-flags.ts | sed -n '58,105p'

Repository: novuhq/novu

Length of output: 3772


MAX_ENVIRONMENT_COUNT won't get a numeric validator.

The filter key.endsWith('_NUMBER') will miss MAX_ENVIRONMENT_COUNT in FeatureFlagsKeysEnum. It's defined as a numeric flag but doesn't follow the _NUMBER suffix convention, so it won't receive a numeric validator.

🤖 Prompt for AI Agents
In `@apps/api/src/config/env.validators.ts` around lines 85 - 92, The numeric
validator block is skipping MAX_ENVIRONMENT_COUNT because the filter uses
key.endsWith('_NUMBER'); update the filter or add an explicit inclusion so
MAX_ENVIRONMENT_COUNT gets a numeric validator: modify the .filter(...) used on
Object.keys(FeatureFlagsKeysEnum) to also accept key === 'MAX_ENVIRONMENT_COUNT'
(or a more general pattern that matches this enum name), ensuring the reduce
still assigns acc[key] = num({ default: undefined }) for that key; reference
FeatureFlagsKeysEnum, the current .filter(key => key.endsWith('_NUMBER')), and
the reducer that sets acc[key] = num(...) when making the change.

Comment on lines +89 to +90
IS_ANALYTICS_PAGE_ENABLED = 'IS_ANALYTICS_PAGE_ENABLED',
IS_LEGACY_SELECTOR_BUTTON_VISIBLE = 'IS_LEGACY_SELECTOR_BUTTON_VISIBLE',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n packages/shared/src/types/feature-flags.ts | head -120

Repository: novuhq/novu

Length of output: 7466


🏁 Script executed:

rg -n "testFlagEnumValidity" --type=ts -A5 -B5

Repository: novuhq/novu

Length of output: 3344


🏁 Script executed:

rg -n "BooleanFlagKey|NumericFlagKey" --type=ts -A2 -B2

Repository: novuhq/novu

Length of output: 841


🏁 Script executed:

rg -n "testFlagEnumValidity.*FeatureFlagsKeysEnum" --type=ts

Repository: novuhq/novu

Length of output: 37


🏁 Script executed:

rg -A5 "export enum FeatureFlagsKeysEnum" packages/shared/src/types/feature-flags.ts

Repository: novuhq/novu

Length of output: 412


IS_LEGACY_SELECTOR_BUTTON_VISIBLE violates the BooleanFlagKey naming convention.

The BooleanFlagKey type (line 5) requires flags to end with _ENABLED or _DISABLED, but IS_LEGACY_SELECTOR_BUTTON_VISIBLE ends with _VISIBLE. Rename to follow the pattern.

Suggested fix
-  IS_LEGACY_SELECTOR_BUTTON_VISIBLE = 'IS_LEGACY_SELECTOR_BUTTON_VISIBLE',
+  IS_LEGACY_SELECTOR_BUTTON_ENABLED = 'IS_LEGACY_SELECTOR_BUTTON_ENABLED',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
IS_ANALYTICS_PAGE_ENABLED = 'IS_ANALYTICS_PAGE_ENABLED',
IS_LEGACY_SELECTOR_BUTTON_VISIBLE = 'IS_LEGACY_SELECTOR_BUTTON_VISIBLE',
IS_ANALYTICS_PAGE_ENABLED = 'IS_ANALYTICS_PAGE_ENABLED',
IS_LEGACY_SELECTOR_BUTTON_ENABLED = 'IS_LEGACY_SELECTOR_BUTTON_ENABLED',
🤖 Prompt for AI Agents
In `@packages/shared/src/types/feature-flags.ts` around lines 89 - 90, The enum
value IS_LEGACY_SELECTOR_BUTTON_VISIBLE violates the BooleanFlagKey naming
convention; rename the enum member to follow the _ENABLED/_DISABLED pattern
(e.g., IS_LEGACY_SELECTOR_BUTTON_ENABLED) and update its string value to match,
then update all references/usages (imports, tests, feature-flag lookups, and any
persisted keys) to the new symbol; ensure BooleanFlagKey type usage and any
switch/conditionals that check IS_LEGACY_SELECTOR_BUTTON_VISIBLE are updated to
the new name so compilation and runtime behavior remain correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant