Repository navigation
change props log info to debug - #1228
Conversation
WalkthroughAdjusted logging from info to debug for missing nested data, added an explicit return in the base case of a recursive data retrieval helper to propagate values, and inserted a non-functional extra newline in the function definition area. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant DS as data_source.ts
participant Logger
Caller->>DS: getDataFromSource(source, propPath)
activate DS
alt propPath has multiple segments
DS->>DS: innerGetDataFromSource(nextObj, remainingPath)
note right of DS: Recurses until base case
else base case (one segment)
DS->>DS: retrieve value
note over DS: Explicitly return value
end
opt missing nested data
DS-->>Logger: debug("Missing nested data at ...")
end
DS-->>Caller: value or undefined
deactivate DS
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/graphai/src/utils/data_source.ts (3)
42-48: Short‑circuit when lookup fails to avoid redundant recursion and duplicate logs.If a segment isn’t found, we currently recurse into undefined and log again for each remaining segment. Early‑return instead and treat null as a miss for consistency.
- if (ret === undefined) { - GraphAILogger.debug(`prop: ${propIds.join(".")} is not hit`); - } - if (propIds.length > 1) { - return innerGetDataFromSource(ret, propIds.slice(1), propFunctions); - } - return ret; + if (propIds.length > 1) { + if (isNull(ret)) { + GraphAILogger.debug(`prop not found: ${propIds.join(".")}`); + return undefined; + } + return innerGetDataFromSource(ret, propIds.slice(1), propFunctions); + } + return ret;
37-41: Type-safety: allow undefined input and guard before dereferencing.We can pass undefined into this function via the recursive call; reflect that in the signature and guard up front.
-const innerGetDataFromSource = (result: ResultData, propIds: string[] | undefined, propFunctions: PropFunction[]): ResultData | undefined => { - +const innerGetDataFromSource = (result: ResultData | undefined, propIds: string[] | undefined, propFunctions: PropFunction[]): ResultData | undefined => { + if (isNull(result)) { + return undefined; + }
38-38: Nit: remove stray blank line.Keeps the function header tight and consistent with the file’s style.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/graphai/src/utils/data_source.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/graphai/src/utils/data_source.ts (3)
packages/graphai/lib/utils/data_source.js (2)
propId(39-39)getNestedData(7-36)packages/graphai/src/utils/prop_function.ts (1)
propFunctions(157-157)packages/graphai/src/index.ts (1)
GraphAILogger(52-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (22.x)
- GitHub Check: build (24.x)
🔇 Additional comments (1)
packages/graphai/src/utils/data_source.ts (1)
43-43: Good call: downgrade noisy log to debug.Switching missing-path logs from info to debug reduces noise without losing diagnosability.
Summary by CodeRabbit