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

using hiera-http with puppet 4.10 yields Error while evaluating a Function Call, HTTP request path is empty

Open tosmi opened this issue 7 years ago • 4 comments

this has happens because order_override is an empty array [] in my case. dunno where this comes from.

the following code (http_backend.rb line 52) in hiera-http inserts the empty array at position 0 in the paths array:

paths.insert(0, order_override) if order_override

if order_override is an empty array we end up with

[ [ ],"/first", "/second" ]

end the first element [] gets pass all the way down to net/http, which complains rightfully about the empty path.

as a quick fix i changed this to

paths.insert(0, order_override).flatten! if order_override

will open a pull request for this as well.

thanks toni

tosmi avatar Apr 12 '17 12:04 tosmi

I think this is also effecting us, just tried to upgrade our lab to 2017.3 and get the following:

[root@<REMOVED> puppet]# puppet lookup --node <REMOVED>  rhel --explain
Warning: /etc/puppetlabs/puppet/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   (in /etc/puppetlabs/puppet/hiera.yaml)
Warning: Undefined variable 'product';
   (file & line not available)
Warning: Undefined variable 'client_id';
   (file & line not available)
Warning: Undefined variable 'role';
   (file & line not available)
Warning: Undefined variable '::environment';
   (file & line not available)
Warning: Undefined variable 'clientcert';
   (file & line not available)
Warning: Undefined variable 'datacenter';
   (file & line not available)
Warning: Undefined variable 'client_environment';
   (file & line not available)
Warning: Undefined variable 'environment';
   (file & line not available)
Error: Could not run: HTTP request path is empty

dzeleski avatar Oct 12 '17 04:10 dzeleski

Manually patching both rb files from the two gem installs does indeed fix this issue. Any ideas on if a new gem will be published?

dzeleski avatar Oct 12 '17 23:10 dzeleski

@dzeleski Are you using the latest version of hiera-http (from the Puppet module, not from the gem)?

I don't think your errors are related to this issue, but I'm happy to help equally - can you send your hiera.yaml file too?

crayfishx avatar Oct 13 '17 06:10 crayfishx

@crayfishx We are not, Im still using hiera 3. I assumed I still had to use the old 2.0 gem? Should I be using the new 3.0 module even with hiera 3?

---
:backends:
  - http
  - yaml


:logger: console
:merge_behavior: deeper
:deep_merge_options:
  :knockout_prefix: '--'

:hierarchy:
  - "nodes/%{clientcert}"
  - "%{datacenter}/products/%{product}/clients/%{client_id}/roles/%{role}"
  - "%{datacenter}/products/%{product}/clients/%{client_id}"
  - "%{datacenter}/products/%{product}/roles/%{role}/client_environments/%{client_environment.type}"
  - "%{datacenter}/products/%{product}/roles/%{role}"
  - "%{datacenter}/products/%{product}/common"
  - "%{datacenter}_common"

:yaml:
  :datadir: /etc/puppetlabs/code/environments/%{environment}/hieradata

# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows
# When specifying a datadir, make sure the directory exists.

:http:
  :host: <REMOVED>
  :port: 8080
  :output: yaml
  :failure: graceful
  :cache_timeout: 10
  :headers:
    :Authorization: <REMOVED>
  :paths:
    - "/hiera_%{product}/%{client_id}/%{role}"
    - "/hiera_%{product}/%{client_id}/common"

dzeleski avatar Oct 13 '17 15:10 dzeleski