Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid property path when the path contains special characters #2669

Open
blampe opened this issue Nov 25, 2024 · 2 comments
Open

Invalid property path when the path contains special characters #2669

blampe opened this issue Nov 25, 2024 · 2 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@blampe
Copy link
Contributor

blampe commented Nov 25, 2024

What happened?

We seem to generate an invalid property path when it contains dots:

options.["com.docker.network.driver.overlay.vxlanid_list"]:kind:DELETE_REPLACE
...
property path '["com.docker.network.driver.overlay.vxlanid_list"]' contains a '.' followed by a '['; this is not strictly legal

The correct syntax is options["com.docker.network.driver.overlay.vxlanid_list"].

The relevant field type is

"options": {
    "type": "object",
    "additionalProperties": {
        "type": "string"
    },
    "description": "Only available with bridge networks. See [bridge options docs](https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options) for more details.\n"
},

I'm guessing this has something to do with the one untested line in diff.go:

elementPath = fmt.Sprintf(`%s.["%s"]`, path, strings.ReplaceAll(string(k), `"`, `\"`))

Example

pulumi/pulumi-docker#1284 provides a repro. Run docker swarm init beforehand.

{
  "name": "p-docker-1284",
  "main": "index.ts",
  "devDependencies": {
    "@types/node": "^18",
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@pulumi/pulumi": "^3.113.0",
    "@pulumi/docker": "^4"
  }
}
import * as docker from "@pulumi/docker";

new docker.Network("network", {
  name: "p-docker-1284",
  driver: "overlay",
  options: { encrypted: "true" },
});
I1125 10:46:35.954337    3221 provider_plugin.go:1009] Provider[docker, 0x1400208a780].Diff(urn:pulumi:dev::p-docker-1284::docker:index/network:Network::network,xmmck7rxhzj4rnib2qsi8423y) success: changes=2 #replaces=[options] #stables=[attachable checkDuplicate driver ingress internal ipamConfigs ipamDriver ipamOptions ipv6 labels name] delbefrepl=true, diffs=#[options], detaileddiff=map[options:kind:UPDATE options.["com.docker.network.driver.overlay.vxlanid_list"]:kind:DELETE_REPLACE]
I1125 10:46:35.954350    3221 properties_path.go:85] property path '["com.docker.network.driver.overlay.vxlanid_list"]' contains a '.' followed by a '['; this is not strictly legal

Output of pulumi about

CLI
Version      3.140.0
Go Version   go1.23.3
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  docker  4.5.7
language  nodejs  3.140.0-dev.0

Host
OS       darwin
Version  14.6.1
Arch     arm64

This project is written in nodejs: executable='/opt/homebrew/bin/node' version='v22.6.0'

Current Stack: organization/p-docker-1284/dev

TYPE                          URN
pulumi:pulumi:Stack           urn:pulumi:dev::p-docker-1284::pulumi:pulumi:Stack::p-docker-1284-dev
pulumi:providers:docker       urn:pulumi:dev::p-docker-1284::pulumi:providers:docker::default_4_5_7
docker:index/network:Network  urn:pulumi:dev::p-docker-1284::docker:index/network:Network::network


Found no pending operations associated with dev

Backend
Name           Bryces-Work-MacBook-Pro.local
URL            file:///Users/bryce/src/test/p-docker-1284/
User           bryce
Organizations
Token type     personal

Dependencies:
NAME            VERSION
typescript      5.7.2
@pulumi/docker  4.5.7
@pulumi/pulumi  3.141.0
@types/node     18.19.65

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@blampe blampe added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 25, 2024
@VenelinMartinov VenelinMartinov removed the needs-triage Needs attention from the triage team label Nov 26, 2024
@VenelinMartinov
Copy link
Contributor

Thanks for reporting and for pointing us to the problematic code. I've added tests which repro the issue in #2671. Will investigate a solution.

@VenelinMartinov VenelinMartinov self-assigned this Nov 26, 2024
@VenelinMartinov
Copy link
Contributor

The untested line isn't the only problem it looks like. After fixing it locally the provider still fails to return a valid detailed diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants