carvel-dev / carvel-dev/ytt

template.replace() can't replace a map item with the same key

Open
#704 0 comments 1 reaction 0 assignees View on GitHub
bug priority/unprioritized-backlog
Dominant language
Go
Stars
1.9k
Forks
167
PR merge metrics
No merged PRs in 30d

Description

**What steps did you take:**
```yaml
#@ load("@ytt:template", "template")
_: #@ template.replace({"_": "1"})
```

**What happened:**
```console
ytt: Error:
- template.replace: expected to find placeholder map item in map
in
ex2.yaml:2 | _: #@ template.replace({"_": "1"})
```

**What did you expect:**
The map item to simply be replaced.

**Anything else you would like to add:**
[#carvel @ 2022-07-11](https://kubernetes.slack.com/archives/CH8KCCKA5/p1657433680791589)

**Environment:**

- ytt version (use `ytt --version`):
- OS (e.g. from `/etc/os-release`):

---
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

Open the contributing guide

Research direction

Start by reproducing the template.replace example from ex2.yaml with ytt and trace the template.replace entry point that reports the missing placeholder map item. Confirm the map item is replaced when the placeholder and replacement use the same key, while preserving the existing error behavior for genuinely missing placeholders.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.