Skip to content

fix(registeredscript): resolve version diff detection issue#52

Merged
JDetmar merged 1 commit intomainfrom
fix/registeredscript-version-diff-followup
Jan 12, 2026
Merged

fix(registeredscript): resolve version diff detection issue#52
JDetmar merged 1 commit intomainfrom
fix/registeredscript-version-diff-followup

Conversation

@JDetmar
Copy link
Copy Markdown
Owner

@JDetmar JDetmar commented Jan 12, 2026

Summary

This fixes an issue where RegisteredScript would always detect a version diff even when the version hadn't changed, causing unnecessary replacements that broke SiteCustomCode (Issue 2).

Root cause: Pulumi's struct embedding doesn't properly deserialize the version field into the embedded RegisteredScriptResourceArgs struct, causing req.State.Version to be empty during Diff comparison.

Changes:

  • Made version field optional in struct tag for backwards compatibility with existing state (Create still validates version is provided)
  • Updated Diff method to only compare version when both state and inputs have non-empty values

Test plan

  • Unit tests pass (make test_provider)
  • Live API testing confirms:
    • RegisteredScript no longer falsely detects version diffs
    • SiteCustomCode works correctly with RegisteredScript
    • siteCustomCodeUpdated output shows valid timestamp

Related Issues

Updates ISSUES-TO-FIX.md:

  • Issue 1 (RegisteredScript Update 404): ✅ Already fixed in PR fix(registeredscript): all changes now trigger replacement instead of update #51
  • Issue 2 (SiteCustomCode Script ID Format): ✅ Resolved by this PR (was blocked by Issue 4)
  • Issue 4 (RegisteredScript Version Diff): ✅ Fixed by this PR
  • Issue 5 (Asset Variants Parsing): ❌ New issue documented
  • Issue 6 (CollectionItem Slug Uniqueness): ❌ New issue documented

🤖 Generated with Claude Code

This fixes an issue where RegisteredScript would always detect a version
diff even when the version hadn't changed, causing unnecessary replacements.

Root cause: Pulumi's struct embedding doesn't properly deserialize the
version field into the embedded RegisteredScriptResourceArgs struct,
causing req.State.Version to be empty during Diff comparison.

Changes:
- Made version field optional in struct tag for backwards compatibility
  with existing state (Create still validates version is provided)
- Updated Diff method to only compare version when both state and inputs
  have non-empty values

Also updates ISSUES-TO-FIX.md with resolution status for Issues 1, 2, and 4,
and documents two new issues discovered during testing (Asset variants
parsing and CollectionItem slug uniqueness).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 12, 2026 05:49
@github-actions
Copy link
Copy Markdown
Contributor

Does the PR have any schema changes?

Found 1 breaking change:

Resources

  • 🟢 "webflow:index:RegisteredScript": required: "version" property is no longer Required
    No new resources/functions.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical issue where RegisteredScript resources would incorrectly detect version changes on every Pulumi run, causing unnecessary resource replacements that broke dependent SiteCustomCode resources. The root cause was Pulumi's struct embedding not properly deserializing the version field into the embedded struct during Diff operations.

Changes:

  • Made the version field optional in the schema and provider struct tags for backwards compatibility with existing state
  • Updated the Diff method to only compare versions when both state and input values are non-empty, preventing false positives
  • Validation in the Create method still requires version to be provided for new resources

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
provider/registeredscript_resource.go Added optional tag to Version field and updated Diff logic to handle empty state versions from deserialization issues
provider/cmd/pulumi-resource-webflow/schema.json Removed version from required fields list
sdk/python/pulumi_webflow/registered_script.py Made version optional parameter (moved after can_copy), removed constructor validation, changed return type to Optional
sdk/nodejs/registeredScript.ts Made version optional in args interface and changed output type to allow undefined
sdk/go/webflow/registeredScript.go Changed Version to StringPtrOutput and removed constructor validation
sdk/java/src/main/java/io/github/jdetmar/pulumi/webflow/RegisteredScriptArgs.java Made version @nullable, removed required=true, changed return type to Optional, removed validation
sdk/java/src/main/java/io/github/jdetmar/pulumi/webflow/RegisteredScript.java Changed version output to Optional wrapper
sdk/dotnet/Webflow/RegisteredScript.cs Made version nullable string and removed required attribute
ISSUES-TO-FIX.md Updated status for resolved issues and documented new issues discovered during testing

@JDetmar JDetmar merged commit 869c850 into main Jan 12, 2026
22 checks passed
@JDetmar JDetmar deleted the fix/registeredscript-version-diff-followup branch January 12, 2026 06:02
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.

2 participants