PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Critical Issue with Visual Studio's Rename Functionality Causing Code Corruption

Open vsfeedback opened this issue 10 months ago • 2 comments

This issue has been moved from a ticket on Developer Community.


[severity:Other]
Description:

There is a critical issue in Visual Studio’s rename functionality for Python code. After renaming the function print_exception to print_error using the F2 shortcut, the IDE caused an error in one file where part of the code was incorrectly modified. Specifically, the line:

append_jsonl(best_moments, reels_path)
append_text('\n', reels_path)
except Exception as ex:
    print_exception(ex, False, 'LLM response processing error: ')
    append_text(llm_response + '\n\n', reels_path)
  

was altered to:

print_errorbest_moments, reels_path)
append_text('\n', reels_path)
except Exception as ex:
    print_exception(ex, False, 'LLM response processing error: ')
    append_text(llm_response + '\n\n', reels_path)
  

This issue is highly difficult to reproduce, but its potential consequences are severe. The root cause seems to be related to file caching, code desynchronization, or other inconsistencies between the code and the IDE’s internal state. The primary goal of this ticket is to inform the development team about a critical problem with the rename functionality in Visual Studio that could cause silent failures in the codebase. It is not intended to help me fix the specific instance; I can manually correct the function name, but the issue itself needs to be addressed at the IDE level to prevent further incidents.

Function declaration in one file: 2024-12-26_150529.png Second file. Function import: 2024-12-26_150633.png Second file. Successful renaming: 2024-12-26_150700.png Second file. Malicious renaming: 2024-12-26_150732.png


Original Comments

Vitaliy on 12/26/2024, 07:52 AM:

Please note that " append_jsonl(" which was replaced by "print_error" has the same length as "print_exception", both being 15 characters long.

Feedback Bot on 12/26/2024, 06:04 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

vsfeedback avatar Jan 08 '25 18:01 vsfeedback

can the file with broken changes could have been modified while renaming is going on? did user do anything once invoked the rename?

heejaechang avatar Jan 08 '25 21:01 heejaechang

No, the file wasn't modified either in Visual Studio or externally during renaming. Moreover, the renaming operation took less than a second. Most likely, Visual Studio simply cached outdated variable indexes (desynchronization).

Viamo avatar Jan 08 '25 21:01 Viamo