Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 65 additions & 25 deletions ISSUES-TO-FIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,36 @@ Issues discovered during testing session on 2026-01-09.

## 1. RegisteredScript Update Returns 404

**Status:** ✅ FIXED in PR #51

**File:** `provider/registeredscript_resource.go` (Update method)

**Problem:** When Pulumi detects a diff in RegisteredScript (e.g., version change), it calls the Update method which uses `PutRegisteredScript`. The Webflow API returns 404.

**Error:**
```
error: failed to update registered script: not found: the Webflow site or robots.txt configuration does not exist.
```
**Root Cause:** Webflow API v2 does not support PATCH/PUT for registered scripts. Only GET (list), POST (create), and DELETE are available.

**Investigation needed:**
- Check if Webflow's API supports updating registered scripts at all
- Verify the PUT endpoint URL is correct
- May need to implement as delete+recreate instead of update
**Solution:** Changed all field changes to trigger replacement (delete + recreate) instead of in-place update. All changes now use `p.UpdateReplace` in the Diff method with `DeleteBeforeReplace = true`.

---

## 2. SiteCustomCode Script ID Format

**Status:** ✅ RESOLVED (was blocked by Issue 1 & 4)

**File:** `provider/sitecustomcode_resource.go`

**Problem:** When creating SiteCustomCode with a registered script, the API returns "invalid id and version".

**Error:**
```
error: failed to create site custom code: bad request: {"message":"Bad Request: At least one script contained an invalid id and version","code":"bad_request"}
```
**Root Cause:** This issue was caused by Issues 1 and 4. When RegisteredScript had problems (update 404 errors, false version diffs triggering unnecessary replacements), the script ID would become unknown during replacement, causing SiteCustomCode validation to fail.

**Investigation needed:**
- Verify what format the `id` field expects (displayName vs script ID)
- Check if version must match exactly what's registered
- Test with hardcoded values to isolate the issue
- May be blocked until RegisteredScript issues are resolved
**Resolution:** After fixing Issues 1 and 4, SiteCustomCode works correctly. The script ID format (human-readable string derived from displayName) is correct as documented.

---

## 3. getTokenInfo / getAuthorizedUser Invoke Functions Crash

**Status:** ❌ NOT YET INVESTIGATED

**Files:** `provider/token.go`, `provider/authorized_user.go`

**Problem:** When using these invoke functions in Pulumi YAML, the provider crashes with gRPC errors.
Expand All @@ -59,18 +52,64 @@ error: rpc error: code = Unknown desc = invocation of webflow:index:getTokenInfo

## 4. RegisteredScript Version Diff on Every Run

**Status:** ✅ FIXED in PR #51 + additional fix

**File:** `provider/registeredscript_resource.go` (Diff method)

**Problem:** Even after refresh, Pulumi keeps detecting a version diff on RegisteredScript, triggering unnecessary updates.

**Root cause:** Webflow's list scripts API doesn't return the `version` field. The Read method preserves version from state, but something causes Diff to still see a change.
**Root Causes:**

1. All changes should trigger replacement, not update (fixed in PR #51)
2. Pulumi's struct embedding doesn't properly deserialize the version field into the embedded `RegisteredScriptResourceArgs` struct, causing `req.State.Version` to be empty when compared

**Solution:**

- Changed version field back to optional in struct tag (for backwards compatibility with existing state)
- Updated Diff method to only compare version if both state and inputs have non-empty values
- Create method still validates that version is provided for new resources

---

## 5. Asset Variants Parsing Error (NEW)

**Status:** ❌ NOT YET FIXED

**Workaround applied:** Made `version` optional in schema (line 43), but this may have side effects.
**File:** `provider/asset.go`

**Problem:** The Asset resource fails to read with a JSON parsing error.

**Error:**
```
error: Preview failed: failed to read asset: failed to parse response: json: cannot unmarshal array into Go struct field AssetResponse.variants of type map[string]provider.AssetVariant
```

**Root Cause:** The Webflow API returns `variants` as an array, but the Go struct expects a map.

**Investigation needed:**
- Debug what values Diff receives for `req.State.Version` vs `req.Inputs.Version`
- May need to adjust how Read populates the response
- Consider if version should trigger replacement instead of update

- Update the `AssetResponse` struct to handle `variants` as an array
- Check Webflow API documentation for the correct variants format

---

## 6. CollectionItem Slug Uniqueness Error (NEW)

**Status:** ❌ NOT YET FIXED

**File:** `provider/collectionitem_resource.go`

**Problem:** When updating a CollectionItem, the API rejects the request with a slug uniqueness error even when the slug hasn't changed.

**Error:**

```text
error: failed to update collection item: bad request: {"message":"Validation Error","code":"validation_error","details":[{"param":"slug","description":"Unique value is already in database: 'test-blog-post'"}]}
```

**Root Cause:** The update request includes the unchanged slug, and Webflow rejects it because the slug already exists (for the same item).

**Fix needed:** Exclude unchanged slug from PATCH requests, similar to the fix applied for Collection resource.

---

Expand All @@ -82,9 +121,10 @@ Test stack is at `/private/tmp/test-webflow` with these working resources:
- RobotsTxt
- Collection (with new `collectionId` output)
- CollectionField
- CollectionItem
- CollectionItem (note: has slug update issue)
- Webhook
- AssetFolder
- RegisteredScript (Read works, Update broken)
- RegisteredScript ✅ (fully working)
- SiteCustomCode ✅ (fully working)

SiteCustomCode is defined but not yet created due to above issues.
Asset is temporarily commented out due to variants parsing bug.
6 changes: 2 additions & 4 deletions provider/cmd/pulumi-resource-webflow/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,7 @@
"siteId",
"displayName",
"hostedLocation",
"integrityHash",
"version"
"integrityHash"
],
"inputProperties": {
"canCopy": {
Expand Down Expand Up @@ -975,8 +974,7 @@
"siteId",
"displayName",
"hostedLocation",
"integrityHash",
"version"
"integrityHash"
]
},
"webflow:index:RobotsTxt": {
Expand Down
15 changes: 13 additions & 2 deletions provider/registeredscript_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ type RegisteredScriptResourceArgs struct {
// Version is the Semantic Version (SemVer) string for the script.
// Format: "major.minor.patch" (e.g., "1.0.0", "2.3.1")
// See https://semver.org/ for more information.
Version string `pulumi:"version"`
// Note: Marked optional for backwards compatibility with existing state, but
// Create validates that version is provided for new resources.
Version string `pulumi:"version,optional"`
// CanCopy indicates whether the script can be copied on site duplication.
// Default: false
CanCopy bool `pulumi:"canCopy,optional"`
Expand Down Expand Up @@ -146,7 +148,16 @@ func (r *RegisteredScriptResource) Diff(
detailedDiff["integrityHash"] = p.PropertyDiff{Kind: p.UpdateReplace}
}

if req.State.Version != req.Inputs.Version {
// Compare version - only if state has a non-empty version.
// If state version is empty (from old state before field was required),
// check if the current state outputs have version set. If they don't differ
// from inputs, no change is needed.
// Note: Due to struct embedding, the state version might not deserialize correctly
// in some cases. We handle this by only flagging a diff if both versions are
// non-empty AND different.
stateVersion := req.State.Version
inputVersion := req.Inputs.Version
if stateVersion != "" && inputVersion != "" && stateVersion != inputVersion {
detailedDiff["version"] = p.PropertyDiff{Kind: p.UpdateReplace}
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/dotnet/Webflow/RegisteredScript.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions sdk/go/webflow/registeredScript.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions sdk/nodejs/registeredScript.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading