Skip to content

S-137651 Include custom text fields and tags to redaction script - #53

Open
hariharan-digitalai wants to merge 5 commits into
masterfrom
S-137651
Open

hariharan-digitalai wants to merge 5 commits into
masterfrom
S-137651

Conversation

@hariharan-digitalai

Copy link
Copy Markdown

Updated the story redaction script to:

  • Redact configured custom text and custom long-text fields.
  • Delete tags associated with the story.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new script has a confirmed failure mode in custom-field parsing and risky defaults that can lead to unintended deletions without explicit operator configuration.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR replaces the existing one-off story redaction SQL script with a new script that additionally supports redacting configured custom text/long-text fields and removing story tags, while continuing to delete related commit/webhook event records that reference the redacted fields.

Changes:

  • Removed the legacy redact-story-name-and-description.sql script.
  • Added redact-story-multiple-fields.sql to redact Name/Description plus custom text/long-text fields and delete story tags.
  • Extended the commit/webhook event cleanup filters to include tag and custom-field payload references.
File summaries
File Description
one-off/redact-story-name-and-description.sql Removed legacy one-off script in favor of a more capable replacement.
one-off/redact-story-multiple-fields.sql New one-off script to redact additional fields (custom text/long-text) and delete tags, plus expanded event cleanup.
Review details

Suppressed comments (1)

one-off/redact-story-multiple-fields.sql:78

  • Same as above for CustomLongText: use = instead of IN and guard for NULL so the update is a deliberate opt-in.
update dbo.LongString
set Value=@redacted
from dbo.CustomLongText
where LongString.ID=CustomLongText.Value and CustomLongText.ID=@storyId
and CustomLongText.Definition in (@customLongTextDefinition)
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread one-off/redact-story-multiple-fields.sql Outdated
Comment thread one-off/redact-story-multiple-fields.sql Outdated
Comment thread one-off/redact-story-multiple-fields.sql Outdated
- updated header comment
- used = instead in for definition comparison
if @error<>0 goto ERR
raiserror('%d Custom Long Text redacted', 0, 1, @rowcount) with nowait

delete dbo.BaseAssetTaggedWith

@dgilbertdigital dgilbertdigital Sep 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just deleting all tags for a story. They want to update specific tags to be "redacted" similar to how the rest of the code in this file does. Also, I believe they wanted that to be a completely different script so they could run the tags separately.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated script to redact tags instead of deleting them and moved to separate script file - 4e74fe3


declare @workitemNumber int=NNNNN
declare @assetType varchar(100)=NULL -- e.g. 'Story'
declare @tagValue varchar(440)=NULL -- e.g. 'all'

@spazmodius spazmodius Sep 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a confusing comment. Will @tagValue varchar(440)='all' redact all the workitem's tags?

The instructions in the header block give no guidance on setting @tagValue

Comment on lines +28 to +30
update dbo.BaseAssetTaggedWith
set Value=@replaceWith
where ID=@workitemId and Value=@tagValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any given asset must not have the same tag multiple times at any point in history. We are not protecting against this, which can happen if redacted is a real tag, or if the user runs this script multiple times for different @tagValues

Comment on lines +10 to +11
declare @tagValue varchar(440)=NULL -- e.g. 'all'
declare @replaceWith varchar(440)='redacted'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tags are nvarchar


delete dbo.Commits
where cast(Payload as varchar(max)) like '%Asset":"'+@workitemOid
and cast(Payload as varchar(max)) like '%"Name":"TaggedWith"%Value":"'+@tagValue+'"%'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't @tagValue need to be JSON-encoded to match?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants