Skip to content

[Bug]: Copilot setup crashes on a non-UTF-8 VS Code settings file #3831

Description

@marcelsafin

Bug Description

Copilot setup preserves an existing .vscode/settings.json when it cannot parse
the file, but a non-UTF-8 file escapes that preservation path and aborts setup
with a raw UnicodeDecodeError. _merge_vscode_settings catches
json.JSONDecodeError and OSError; Path.read_text(encoding="utf-8") raises
the sibling UnicodeDecodeError first.

Steps to Reproduce

  1. Create .vscode/settings.json containing non-UTF-8 bytes such as ff fe.
  2. Run Copilot integration setup on current main.
  3. Setup aborts while reading the existing settings file.

Expected Behavior

Treat the file like the existing JSONC/invalid-JSON path: preserve it, skip the
merge, and emit the existing manual-settings warning.

Actual Behavior

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Specify CLI Version

0.14.4.dev0 (main)

AI Agent

GitHub Copilot

Operating System

macOS

Python Version

Python 3.13.11

Error Logs

UnicodeDecodeError
'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Additional Context

I'd like to fix this by routing UnicodeDecodeError through the existing
preservation/warning branch and adding a regression test that drives
CopilotIntegration.setup with a non-UTF-8 settings file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions