BUG: Codex is producing invalid Obj-C code. Python script generated to replace code breaks existing code

Resolved 💬 3 comments Opened Sep 16, 2025 by guidedways Closed Nov 11, 2025
💡 Likely answer: A maintainer (guidedways, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.36.0

Which model were you using?

gpt-codex-high

What platform is your computer?

macOS

What steps can reproduce the bug?

Codex seems to write Python script to mass update existing code with bogus code - it's replacement patterns are too loose and broad and causes mayhem across the entire codebase:

example (obj-c code):

  SharedPreferences.alarmsStartOfWeek = Preferences.startOfWeek;

got turned into:

 Shared[TaskManager sharedManager].preferences.alarmsStartOfWeek = [TaskManager sharedManager].preferences.startOfWeek;

apparently it was trying to find and replace Preferences.alarmsStartOfWeek with [TaskManager sharedManager].preferences.alarmsStartOfWeek and ended up doing it across the entire codebase incorrectly.

What is the expected behavior?

It should have matched the start of word or line etc instead of doing a full X → Y replacement

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

3 Comments

guidedways contributor · 11 months ago

Codex is also producing incorrect Obj-C code:

    [[TaskManager sharedManager] preferences] setBackupFolder:nil;

Notice the missing ]

Original line was

[TaskManager sharedManager].preferences.backupFolder = nil;

which it replaced with a setter upon request but ended up doing it incorrectly.

guidedways contributor · 11 months ago

Codex is also adding Swift code to Obj-C code:

It added the following to a .m file:

self.mutablePreferences = [TaskPreferencesSnapshot captureCurrent()];

It should have been

self.mutablePreferences = [TaskPreferencesSnapshot captureCurrent];
etraut-openai contributor · 9 months ago

Thanks for the bug report. We've shared the feedback with the team members who are responsible for training our codex models. We're tracking this feedback and similar reports so we can make the model more robust in future iterations.

If you see other model behavior that you'd like to report, please use the recently-added /feedback command in the CLI. That will provide us with additional details including logs and conversation text.