PTVS
PTVS copied to clipboard
Critical Issue with Visual Studio's Rename Functionality Causing Code Corruption
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:
Second file. Function import:
Second file. Successful renaming:
Second file. Malicious renaming:

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.
can the file with broken changes could have been modified while renaming is going on? did user do anything once invoked the rename?
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).