fix: resolve 3 bugs — cacheHitRate, null depth, checkpoint TypeError#581
fix: resolve 3 bugs — cacheHitRate, null depth, checkpoint TypeError#581rafaelscosta wants to merge 1 commit intoSynkraAI:mainfrom
Conversation
…oint TypeError - config-loader: use (cacheHits + cacheMisses) as denominator for cacheHitRate instead of loads (disk-only), preventing rates >100% (fixes SynkraAI#499) - yaml-validator: add null guard in getMaxDepth inner loop to prevent null values from inflating depth count (fixes SynkraAI#512) - build-state-manager: guard against undefined checkpoints array in getLastCheckpoint to prevent TypeError (fixes SynkraAI#513) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@rafaelscosta is attempting to deploy a commit to the Pedro Valério Lopez's projects Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR fixes three distinct bugs: correcting cache hit rate calculation to use actual cache interactions as denominator, adding a null guard to prevent TypeError when retrieving checkpoints, and excluding null values from YAML depth calculations. The manifest metadata is also updated. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.aiox-core/core/utils/yaml-validator.js (1)
257-266:⚠️ Potential issue | 🟠 MajorGuard
getMaxDepth()against cyclic aliases, not justnull.
validateGeneral()records circular YAML viaJSON.stringify, but it still callsgetMaxDepth()afterward. A self-referential alias will still recurse forever here and turn a validation result into aRangeError.Proposed fix
- getMaxDepth(obj, currentDepth = 0) { + getMaxDepth(obj, currentDepth = 0, ancestors = new WeakSet()) { if (typeof obj !== 'object' || obj === null) { return currentDepth; } + if (ancestors.has(obj)) { + return currentDepth; + } + ancestors.add(obj); let maxDepth = currentDepth; for (const value of Object.values(obj)) { if (typeof value === 'object' && value !== null) { - const depth = this.getMaxDepth(value, currentDepth + 1); + const depth = this.getMaxDepth(value, currentDepth + 1, ancestors); maxDepth = Math.max(maxDepth, depth); } } + ancestors.delete(obj); return maxDepth; }As per coding guidelines,
Verify error handling is comprehensive with proper try/catch and error context.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.aiox-core/core/utils/yaml-validator.js around lines 257 - 266, The getMaxDepth(obj, currentDepth = 0) helper must guard against cyclic/self-referential YAML aliases (not only null), so modify getMaxDepth to accept or create a visited set/WeakSet and skip traversing any object already seen to avoid infinite recursion; update calls from validateGeneral (which serializes circular refs) to pass a new visited container when kicking off the recursion. Specifically, in getMaxDepth ensure you check visited.has(obj) before recursing, add obj to visited when first encountered, and use a WeakSet to avoid memory leaks so circular structures return a finite depth instead of causing a RangeError.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.aiox-core/core/utils/yaml-validator.js:
- Around line 257-266: The getMaxDepth(obj, currentDepth = 0) helper must guard
against cyclic/self-referential YAML aliases (not only null), so modify
getMaxDepth to accept or create a visited set/WeakSet and skip traversing any
object already seen to avoid infinite recursion; update calls from
validateGeneral (which serializes circular refs) to pass a new visited container
when kicking off the recursion. Specifically, in getMaxDepth ensure you check
visited.has(obj) before recursing, add obj to visited when first encountered,
and use a WeakSet to avoid memory leaks so circular structures return a finite
depth instead of causing a RangeError.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d3c6f7b4-ac0d-47b2-897c-f086fb55bfda
📒 Files selected for processing (4)
.aiox-core/core/config/config-loader.js.aiox-core/core/execution/build-state-manager.js.aiox-core/core/utils/yaml-validator.js.aiox-core/install-manifest.yaml
🔍 Maintainer Review — @devops (Gage)Good work on fixing 3 bugs (#499, #512, #513). The fixes are clean and correct:
However, this PR does NOT fix #497 ( We'll address #497 in a separate dedicated fix branch. CodeRabbit: ✅ APPROVED |
|
Atenção @Pedrovaleriolopez @oalanicolas — esse PR aborda exatamente os mesmos 3 bugs que já temos PRs abertos há mais de 2 semanas:
Os 3 PRs originais já estavam com testes, rebased em main e prontos pra merge. Seria justo dar prioridade aos PRs que chegaram primeiro, não? |
Summary
Fixes 3 reported bugs in a single PR:
getPerformanceMetrics()cacheHitRatedivides byloads(disk-only reads) instead of total requests (cacheHits + cacheMisses), causing rates >100%. Fixed denominator.yaml-validatorgetMaxDepth()inner loop usestypeof value === 'object'without null guard. Sincetypeof null === 'object', null YAML values inflate depth count. Added&& value !== null.build-state-managergetLastCheckpoint()throws TypeError whenthis._state.checkpointsisundefined. Added guard:!this._state.checkpoints ||.Files changed
.aiox-core/core/config/config-loader.jsloads→cacheHits + cacheMisses.aiox-core/core/utils/yaml-validator.js&& value !== nullin getMaxDepth loop.aiox-core/core/execution/build-state-manager.jsTest plan
build-state-manager.test.js— 49/49 passingCloses #499, closes #512, closes #513
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores