hashicorp / hashicorp/terraform-plugin-sdk

Confusing error message for unit-less durations in "timeouts" block

Open
#130 5 comments 4 reactions 0 assignees View on GitHub
enhancement ui
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

If a user tries to write timeout durations without units, Terraform considers this to be an error:

```hcl
timeouts {
create = 5
update = 5
delete = 5
}
```

However, the error message for this is simply "missing unit in duration", which might be misconstrued as suggesting that the unit can just be added on the end of the number:

```hcl
timeouts {
create = 5m # NOT VALID: must be a string
update = 5m
delete = 5m
}
```

This change then leads to an even less helpful error: "Missing newline after argument".

What this message is really trying to say is that the timeout value must be a string containing a decimal number followed by a unit, like this:

```hcl
timeouts {
create = "5m"
update = "5m"
delete = "5m"
}
```

It would be helpful to make this message more complete to avoid misleading the user.

Contributor guide

Open the contributing guide

Research direction

No file or test is named in the issue. Start by locating the timeout duration validation and its existing error-message test, then reproduce the unit-less value example. Done means the error clearly says the value must be a quoted string containing a decimal number and unit, with coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.