Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jul 9, 2025

Description

Fixes the issue where empty or null custom modes configuration files (custom_modes.yaml or .roomodes) cause a 'Cannot read properties of null (reading customModes)' error.

Problem

When the custom modes configuration file exists but is empty or contains null/undefined content, the YAML parser returns null, which causes a null pointer exception when trying to access the customModes property.

Solution

  1. SimpleInstaller.ts:

    • Modified installMode and removeMode methods to ensure existingData is always a valid object after yaml.parse
    • Added explicit checks to convert null/undefined to an empty object with customModes array
    • Ensures customModes array is always initialized before use
  2. CustomModesManager.ts:

    • Modified parseYamlSafely to return an empty object ({}) instead of null when yaml.parse returns null/undefined
    • This prevents null pointer exceptions in downstream code

Testing

  • Added comprehensive test cases for handling empty files, null content, and missing customModes property
  • Updated existing tests to match the correct behavior
  • All tests pass successfully

Verification

The fix ensures that:

  • Empty custom modes files are handled gracefully
  • Files with null content (e.g., '---\n') are properly initialized
  • Files without customModes property get the property added
  • The file structure is always valid after any operation

This resolves the reported error and ensures robust handling of edge cases in custom modes configuration files.


Important

Fixes null pointer exceptions by ensuring customModes is always initialized in SimpleInstaller.ts and CustomModesManager.ts.

  • Behavior:
    • Fixes null pointer exception in SimpleInstaller.ts and CustomModesManager.ts by ensuring customModes is always initialized.
    • parseYamlSafely in CustomModesManager.ts returns {} instead of null.
    • installMode and removeMode in SimpleInstaller.ts handle empty or null .roomodes files by initializing customModes.
  • Testing:
    • Adds tests in SimpleInstaller.spec.ts for empty, null, and missing customModes cases.
    • Verifies correct behavior for invalid YAML and JSON scenarios.
  • Misc:
    • Minor refactoring for error handling and initialization logic.

This description was created by Ellipsis for bd517da. You can customize this summary. It will automatically update as commits are pushed.

…perties of null' error

- Fix SimpleInstaller to ensure existingData is always an object after yaml.parse
- Fix CustomModesManager.parseYamlSafely to return empty object instead of null
- Ensure customModes array is always initialized in both install and remove operations
- Add tests for empty/null file handling scenarios
- Update existing tests to match correct behavior
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners July 9, 2025 20:22
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 9, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jul 9, 2025

No security or compliance issues detected. Reviewed everything up to bd517da.

Security Overview
  • 🔎 Scanned files: 3 changed file(s)
Detected Code Changes
Change Type Relevant files
Bug Fix ► CustomModesManager.ts
    Handle null/undefined settings in updateModesInFile and loadModesFromFile
► SimpleInstaller.ts
    Add null/undefined checks for YAML parsing and customModes property
► package.json
    Remove overflow group assignments and prompts button
► SimpleInstaller.spec.ts
    Add test cases for empty/null content handling

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 9, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 9, 2025
…sFromFile

- Ensure settings object exists before accessing customModes property
- Initialize customModes as empty array if undefined
- Prevent 'Cannot read properties of null' error during mode import
- Add proper validation in loadModesFromFile before schema check
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jul 9, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 9, 2025
@daniel-lxs daniel-lxs merged commit 12ae900 into main Jul 9, 2025
20 of 21 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 9, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 9, 2025
@daniel-lxs daniel-lxs deleted the fix/issue-null-custom-modes branch July 9, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants