Repository navigation
refactor: move chat prompt sanitization into codersdk - #28283
Merged
Merged
Conversation
Exports SanitizePromptText (with its helpers) from codersdk instead of coderd/x/chatd so API consumers can sanitize prompt text exactly the way the server stores it. terraform-provider-coderd needs this for the coderd_chat_system_prompt resource, whose semantic equality must match the server's sanitization to avoid false drift; until now it carried a mirrored copy that could rot. Pure move plus callsite updates: no behavior change, tests move along with it.
bpmct
added a commit
to coder/terraform-provider-coderd
that referenced
this pull request
Aug 18, 2026
…ystem_prompt Per review, the create-time overwrite advisory now also fires when the first apply would change include_default_system_prompt away from the deployment's live value, not just when it would overwrite a non-empty prompt. Covered by a direct ModifyPlan table test in the oauth2_provider_settings style. Also leaves a TODO on the mirrored sanitizer pointing at coder/coder#28283, which exports it as codersdk.SanitizePromptText; once the pinned coder/coder includes that commit the local copy goes away.
3 of 5 tasks
ethanndickson
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exports
SanitizePromptText(and its helpers) fromcodersdkinstead ofcoderd/x/chatd, so API consumers can sanitize prompt text exactly the way the server stores it.Why
coder/terraform-provider-coderd#412 adds a
coderd_chat_system_promptresource whosesystem_promptattribute compares values by their sanitized forms (otherwise the trailing newline fromfile("system-prompt.md")is perpetual drift, since the server stores the sanitized value). That currently requires a mirrored copy of the sanitizer in the provider, which can silently rot. Per review there (discussion), the sanitizer should be exported fromcodersdkand imported instead.What
coderd/x/chatd/sanitize.go→codersdk/promptsanitize.go(pure move; package + doc-comment note about why it lives in codersdk)coderd/x/chatd/sanitize_test.go→codersdk/promptsanitize_test.goexp_chats.go,chatd.go,subagent.go,context_prompt.go); no wrapper left behind, single source of truth