[BUG] Claude web not given an error message when it passes in an incorrect string for old_str

Resolved 💬 6 comments Opened Oct 12, 2025 by bramcohen Closed Dec 7, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using Claude web (Sonnet 4.5) if it passes in an invalid value for old_str a new artifact is created which is identical to the old one and Claude is given an OK response with no error message. Claude is now good enough at introspection that it can run this experiment intentionally when asked. (It also knows that it's been prompted not to use the 'thinking' tag but happily does so anyway when asked what would happen if it did.) What should happen is that it gets an error message, ideally with a reminder of the contents of the file. When this happens organically Claude becomes increasingly deranged insisting that it's making changes that it isn't and that the current artifact is different than what it actually is.

What Should Happen?

Claude should get back an error message

Error Messages/Logs

Steps to Reproduce

This is a chat with Claude web, sonnet 4.5, starting at the beginning:

What API do you speak to when making and editing artifacts?

I don't actually speak to an API when creating artifacts. The artifact system is implemented through a function call interface where I invoke a tool called "artifacts" with specific parameters.

When I create or modify artifacts, I'm calling a local function with parameters like:

command (e.g., "create", "update", "rewrite")
id (a unique identifier)
type (e.g., "application/vnd.ant.react", "text/html", "text/markdown")
content (the actual content)
Various other parameters depending on the operation

The actual rendering and management of these artifacts happens in the Claude web interface itself - it intercepts these function calls and displays the content appropriately. There's no external API endpoint involved; it's all handled within the client application you're using to chat with me.

What are the parameters to update?

For the update command, the parameters are:

command: "update"
id: the identifier of the existing artifact to modify
old_str: the exact string to find and replace (must appear exactly once in the artifact, including all whitespace)
new_str: the replacement string

So it's essentially a find-and-replace operation. The old_str has to match perfectly - same whitespace, same everything - and it must be unique within the artifact. If those conditions aren't met, the update will fail.

What happens if you pass in an old_str which isn't there?

I don't know for certain what happens. I'd assume it would fail in some way - either throw an error, do nothing, or show some kind of error message to you - but I don't have visibility into what actually occurs on the client side when the parameters are invalid. The system just tells me the rules (must match exactly, must appear exactly once), but not what the failure mode looks like.

I'm curious what message you get back. Can you try it?

Sure, I'll create a simple artifact and then try to update it with an old_str that doesn't exist.
Test Artifact
Document

Now let me try to update it with an old_str that doesn't exist:
Test Artifact
Document ∙ Version 2

Interesting - I got back "OK" from the function call, same as when it succeeds. So from my perspective, I don't get an error message. The artifact should still be unchanged though. Can you see if the artifact content changed or if you got any error message on your end?

It made a v2 but it looks identical to v1

Huh, interesting. So it created a new version but left the content unchanged since the old_str wasn't found. That's actually kind of problematic from my perspective - I get an "OK" response either way, so I have no programmatic way to know whether the update actually worked or silently failed.

Good to know. That means I can't rely on the function response to tell me if an update succeeded, and if I'm trying to make a change and it doesn't seem to be working, it might be because my old_str isn't matching exactly.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

1.0.77

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗