hashicorp / hashicorp/consul-template

[bug] consul-template does not fail on missing key despite configuration

Open
#1,844 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
4.8k
Forks
801
Avg merge
4h 5m
Merged PRs (30d)
6

Description

### Version

```
consul-template v0.35.0 (2d2654f)
```

### Steps to reproduce

1. Use CLI options list `-once` and `-template-error-fatal=`
2. OR use configuration file as below on screenshot
3. Use template that references key that does not exist
4. Run consul-template with either CLI or config

### Expected outcome
consul-template fails to process template on a key lookup

### Actual outcome
consul-template waits indefinitely for key to appear in KV

### Screenshot

![image](https://github.com/hashicorp/consul-template/assets/985805/2eb77a05-738a-44e2-b46e-4704315372ee)

### References

Are there any other GitHub issues (open or closed) that should
be linked here? For example:
- #1637 was closed as done, but it doesn't work (writing template condition to check whether key exists is quite silly approach in my opinion)

### Suggested solutions (not exclusive)

1. Have a CLI flag that will cause consul-template to exit with error code when a key referenced in template does not exist in KV (or not set via envvars). (generally would be nice to have parity between config file options and CLI arguments).
3. Make a configuration file option `err_on_failed_lookup = true` actually work as advertised
4. Add a default configuration file location (now there seems to be none, judging by the code), for example `/etc/consul-template.[hcl|json]`

Contributor guide

Open the contributing guide

Research direction

Start by tracing handling for the -once and -template-error-fatal CLI options, the err_on_failed_lookup configuration option, and the missing-key lookup path during template rendering. Reproduce the reported behavior with a template referencing an absent KV key, then verify that the selected configuration causes consul-template to fail rather than wait indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.