hiera-http icon indicating copy to clipboard operation
hiera-http copied to clipboard

Literal '%2F' in document name

Open bryanandrews opened this issue 8 years ago • 3 comments

We are using a CouchDB v2 backend and our document names look like this:

  • companya%2Fdev
  • companyb%2Fproduction
  • companyc%2Fwebserver-test-01

We have a web frontend that resolves the literal %2F to a / so it looks pretty in the GUI editor. So our hierarchy uris should be something like this:

  - "http://localhost:5984/configuration/%{fqdn}"
  - "http://localhost:5984/configuration/%{ec2_tag_company}%2F%{ec2_tag_name}"
  - "http://localhost:5984/configuration/%{ec2_tag_company}%2F%{environment}"
  - "http://localhost:5984/configuration/%{ec2_tag_company}"
  - "http://localhost:5984/configuration/%{environment}"
  - "http://localhost:5984/configuration/common"

However hiera_http is turning %2F into %252F during the lookup which means the right document isn't ever found. Is there a way to have literal %2F in the uri?

bryanandrews avatar Feb 16 '18 17:02 bryanandrews

--explain output example:

  URI "http://localhost:5984/configuration/companya%2Fcompanya-dev-03"
    Original uri: "http://localhost:5984/configuration/%{ec2_tag_company}%2F%{ec2_tag_name}"
    No such key: "profiles::jvm::default"
    Returning cached value for /configuration/companya%252Fcompanya-dev-03

It looks like the URI is correct. I can use curl to verify that URI is correct and the output is JSON. However when I see the cached value the doc name isn't correct and I can see the key exists but it isn't found.

bryanandrews avatar Feb 16 '18 17:02 bryanandrews

Curl example showing the URI works:

curl http://localhost:5984/configuration/companya%2Fcompanya-dev-03 {"_id":"companya/companya-dev-03","_rev":"1-9657c4f470e52e081f3d19eec20f269b","profiles::jvm::default":8}

bryanandrews avatar Feb 16 '18 17:02 bryanandrews

I have confirmed that '%2F' in the URI is being translated to '%252F' by looking at the CouchDB access logs which is why it fails.

bryanandrews avatar Feb 16 '18 19:02 bryanandrews