Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zwbproducts
Copy link

πŸ“‹ PR Summary

Branch: fix/silent-json-parse-errors
Target: zwbproducts/kilocode:main
Type: πŸ› Bug Fix

This PR fixes a bug where JSON parsing errors in the combineApiRequests function were silently swallowed, making debugging extremely difficult and potentially causing data loss.


πŸ”— Related Issues

  • Fixes silent error handling anti-pattern
  • Improves debuggability of API request processing
  • See BUGFIX.md for detailed bug documentation

πŸ“ Description

Problem

The combineApiRequests function had empty catch blocks that silently swallowed JSON parsing errors:

try { startData = JSON.parse(startMessage.text) } catch (e) {}  // Silent failure!
try { finishData = JSON.parse(message.text) } catch (e) {}      // Silent failure!

This made it impossible to debug issues when API request/response data was malformed.

Solution

Added proper warning logging with context (including timestamps) while preserving graceful degradation:

try {
    startData = JSON.parse(startMessage.text)
} catch (e) {
    console.warn(
        `[combineApiRequests] Failed to parse api_req_started JSON (ts=${startMessage.ts}):`,
        e instanceof Error ? e.message : String(e)
    )
}

πŸ“ Changes

Modified Files

File Description
src/shared/combineApiRequests.ts Added error logging with timestamp context
src/shared/__tests__/combineApiRequests.spec.ts Added 3 new tests for error logging

Change Statistics

  • Lines Added: ~45
  • Lines Removed: ~4
  • Test Cases Added: 3

πŸ§ͺ Testing

New Tests Added

βœ“ Error logging
  βœ“ should log warning when api_req_started has malformed JSON
  βœ“ should log warning when api_req_finished has malformed JSON
  βœ“ should include timestamp in warning when parsing fails

Verification

  • All existing tests pass
  • New tests cover error logging behavior
  • No TypeScript errors
  • Graceful degradation verified (partial data still returned)

πŸ”„ Changeset

---
"kilo-code": patch
---

Fix silent JSON parse errors in combineApiRequests - now logs warnings for debugging

βœ… PR Checklist

  • Code follows project style guidelines
  • Changes are marked with kilocode_change comments
  • Tests added for new functionality
  • All tests pass
  • No breaking changes
  • Documentation updated (BUGFIX.md)
  • Changeset created

πŸ“Έ Screenshots/Logs

Before (Silent Failure)

// No output when JSON parsing fails - impossible to debug

After (Visible Warning)

[combineApiRequests] Failed to parse api_req_started JSON (ts=1000): Unexpected token 'm' at position 1

πŸš€ Deployment Notes

  • Breaking Changes: None
  • Migration Required: No
  • Feature Flags: None
  • Performance Impact: Minimal (only additional logging on errors)

πŸ‘₯ Reviewers

Please review:

  1. Error message format and context
  2. Test coverage adequacy
  3. Compliance with kilocode_change marking guidelines

πŸ€– AI Code Reviewer Activation

This PR is ready for automated review. The Kilo Code AI reviewer should:

  1. Verify error handling patterns
  2. Check test coverage
  3. Validate TypeScript types
  4. Ensure kilocode_change markers are properly placed

This PR improves the developer experience by making API request processing errors visible and debuggable.

GitHub Copilot and others added 5 commits January 25, 2026 19:47
… found issues

- Add retry logic in ClineProvider.getTaskWithId for fileExistsAtPath check
- Implement comprehensive retry mechanism in safeWriteJson for write operations
- Both retry up to 3 times with 1 second delay between attempts
- Prevents race condition issues when files are temporarily unavailable

Replicates upstream bug fix from kilocode-main
- Replace empty catch blocks with proper console.warn logging
- Include timestamps for debugging context
- Add 3 tests for error logging behavior
- Preserves graceful degradation (no breaking changes)
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

πŸ¦‹ Changeset detected

Latest commit: 6cc623e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant