Confusing 'conditional expression without else clause' error with a yaml error before the if statement
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
**What steps did you take:**
I attempted to template a yaml file with some invalid `yttt` syntax:
```
...
- #@ "--webhook-port={}".format(webhook_port <- MISSING PARENTHESIS
#@ if image_pull_secrets_enabled:
imagePullSecrets:
- name: #@ image_pull_secrets_name
#@ end
```
**What happened:**
An error that suggested that my if block was missing an else clause was thrown:
```
ytt: Error:
- conditional expression without else clause
deployment.yaml:48 | #@ if image_pull_secrets_enabled:
```
**What did you expect:**
Ideally, an error that would point out the line that has the error.
Failing that, an error that would suggest that the issue _might_ be before the if block as the current error seems to strongly suggest that the issue is with the if block.
**Environment:**
- ytt version: `v0.36.0`
---
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
Contributor guide
Research direction
Reproduce the reported template in deployment.yaml with ytt v0.36.0, focusing on the malformed format expression before the if block. Trace how the parser reports the conditional expression, then make the diagnostic identify the earlier syntax error or warn that the problem may precede the if statement.
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
- 35/100