3

I am trying to read .yaml file but getting "found unhashable key" error. Sample code and .yaml is mentioned below for reference

test.py

file_path = "test.yaml"
try:
    with open(file_path) as file:
        res = yaml.safe_load(file)
except Exception as e:
    print("e",e)

test.yaml

jobs:
- job: CLEANUP
  connection:
    dbms: mysql
    user: {{username}}
Ashutosh gupta
  • 447
  • 4
  • 16
  • If you're running into this problem with helm templates, consider just [excluding these files](https://github.com/pre-commit/pre-commit-hooks/issues/420). – Jesse Apr 05 '22 at 17:52

2 Answers2

4

Quote your value,

from {{username}} to "{{username}}"

MukeshRKrish
  • 1,040
  • 5
  • 14
2

Isn't it because of {{username}}? All built-in immutable types are hashable, but mutable ones are not, so hashable types include all numbers, strings (both unicode and bytes) and tuple. Common unhashable types include list, dict and set, and {{username}} is dict syntax.