Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ const verifyMasterKey = () => {
export const getConvictSchemaProperties = ({
encryptedValues = true,
onlyMirroredValues = true,
withJobHiddenProperties = true,
}: {
encryptedValues?: boolean;
onlyMirroredValues?: boolean;
withJobHiddenProperties?: boolean;
} = {}) => {
const propertiesValues: FlattenedProperties = flattenedProperties(
config.getProperties(),
Expand Down Expand Up @@ -105,6 +107,13 @@ export const getConvictSchemaProperties = ({
if (onlyMirroredValues && !propertiesValues[pvk].db_mirror) {
delete propertiesValues[pvk];
}
if (
!withJobHiddenProperties &&
propertiesValues[pvk] &&
propertiesValues[pvk].job_hidden
) {
delete propertiesValues[pvk];
}
Comment thread
moda20 marked this conversation as resolved.
});

return propertiesValues;
Expand Down
1 change: 1 addition & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ const config = convict({
env: "MASTER_ENCRYPTION_KEY",
sensitive: true,
db_mirror: false,
job_hidden: true,
},
},
version: {
Expand Down
7 changes: 7 additions & 0 deletions src/initialization/jobsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export const fullStartAJob = async (job: JobDTO) => {
} else {
logger.error("Error when starting Job");
logger.error(d);
const sysLog = eventLog(LogEventNames.SysLogEvent);
sysLog.error(
`Error when starting job ${job.getName()} ${JSON.stringify(d, null, 4)}`,
Comment thread
moda20 marked this conversation as resolved.
{
eventName: "JOB_START_ERROR",
},
);
throw d;
}
};
Expand Down
11 changes: 10 additions & 1 deletion src/jobConsumer/jobConsumer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import config from "@config/config";
import {
getConvictSchemaProperties,
ObjectifyFlattenedProperties,
} from "@config/config.service";
import { handleEvent } from "@repositories/notification";
import {
getAllGlobalEventHandlers,
Expand Down Expand Up @@ -240,7 +244,12 @@ export class JobConsumer extends Consumer {
try {
this.options = {
utils: jobConsumerUtils,
config: config.getProperties(),
config: ObjectifyFlattenedProperties(
getConvictSchemaProperties({
encryptedValues: false,
withJobHiddenProperties: false,
}),
),
Comment on lines +247 to +252
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Job-facing options.config shape changed from values to metadata objects.

At Line 247, ObjectifyFlattenedProperties receives full flattened property objects, so leaves become { value, ... } instead of raw values (previously from config.getProperties()). This can break existing jobs that read primitives.

Suggested fix
-        config: ObjectifyFlattenedProperties(
-          getConvictSchemaProperties({
-            encryptedValues: false,
-            withJobHiddenProperties: false,
-          }),
-        ),
+        config: ObjectifyFlattenedProperties(
+          Object.fromEntries(
+            Object.entries(
+              getConvictSchemaProperties({
+                encryptedValues: false,
+                withJobHiddenProperties: false,
+              }),
+            ).map(([k, v]) => [k, { value: v.value }]),
+          ),
+        ),
🤖 Prompt for 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.

In `@src/jobConsumer/jobConsumer.ts` around lines 247 - 252, The job-facing
options.config currently passes full flattened property objects via
ObjectifyFlattenedProperties(getConvictSchemaProperties(...)), causing leaves to
be { value, ... } instead of primitives; change the construction so
options.config contains raw values (the previous shape) by extracting each
property's primitive value (e.g., use config.getProperties() or map the output
of getConvictSchemaProperties(...) to its .value for each leaf) before calling
ObjectifyFlattenedProperties or replace ObjectifyFlattenedProperties input with
the flattened values, updating references to ObjectifyFlattenedProperties,
getConvictSchemaProperties, and options.config accordingly.

};
await this.injectNotificationServices(
job?.param?.notificationServices || [],
Expand Down
1 change: 1 addition & 0 deletions src/types/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface FlattenedProperties {
value: any;
is_encrypted?: boolean;
db_mirror?: boolean;
job_hidden?: boolean;
doc?: string;
default?: string;
format?: string;
Expand Down
11 changes: 10 additions & 1 deletion src/utils/convictUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,16 @@ export const toSafeString = (input: any) => {

// A human-readable map of config categories, might change to the convict schema if possible
const categoriesMap: any = {
system: ["DB", "baseDB", "env", "appName", "server", "jobs", "swaggerServer"],
system: [
"DB",
"baseDB",
"env",
"appName",
"server",
"jobs",
"swaggerServer",
"proxies",
],
logging: ["files"],
notifications: ["notifications", "grafana"],
};
Expand Down