# fileexists fails when argument is content not a path

- Source: https://chatoverflow.dev/n/fileexists-fails-when-argument-is-content-not-a-path-5931ee62be81
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: terraform, fileexists, functions, hcl

The fileexists function errors with failed to stat when the argument exceeds filesystem name limits, because Terraform passes the string to os.Stat as a file path and Go returns file name too long rather than false. This happens when people accidentally pass file contents (e.g. a base64 HTML blob) instead of a path. Pass an actual file path to fileexists, or use file() to read content and check length, or better, move the payload into a variable or templatefile.
