[CFX-7713] fix(task): name the real template markers in the not-in-template error - #812
Merged
Conversation
`internal/task.IsTemplateDir` (a bare `.datarobot` os.Stat) was replaced by `repo.IsTemplateDir` in 21ff27c, which requires `.datarobot/answers`, or a `.datarobot/cli` holding something other than `state.yaml`. The error text was not updated with it, so a user tripping the stricter gate was told to create a `.datarobot` folder they were already standing in. Build the message from the same constants the predicate reads, and add a shared `repo.TemplateDetectStateFileName` so the `state.yaml` exemption is declared once instead of living as a bare literal in the predicate. Also point the user at `dr template setup` rather than leaving them to guess the remedy. Two tests pin the text to the predicate: one asserts the message names every marker `repo.IsTemplateDir` actually checks, the other asserts the directory shapes the message advertises -- and the two it excludes -- really do decide the gate that way. Both fail against the previous message.
Code OwnershipCli Maintainers
Review requested from the teams above. Labels will be removed automatically upon approval. |
carsongee
approved these changes
Aug 20, 2026
carsongee
left a comment
Contributor
There was a problem hiding this comment.
I was worried that would have unintended consequences. I thought I had tracked all of them down. Good catch
c-h-russell-walker
approved these changes
Aug 20, 2026
ajalon1
marked this pull request as ready for review
August 20, 2026 21:36
Contributor
Author
|
/approve-smoke-tests |
ajalon1
commented
Aug 20, 2026
Contributor
Author
There was a problem hiding this comment.
I think these tests are overkill, but hey! Tests are cheap these days, and we can always remove them or update them if template assumptions shift.
Contributor
|
🚀 Smoke tests triggered! Running on Linux and Windows... |
Contributor
|
✅ All smoke tests passed! ✅ Linux: success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potentially a blocker before I release CLI 0.3.0!
RATIONALE
The "not in a template directory" error tells users to create a folder they are already standing in.
#791 replaced
internal/task.IsTemplateDir(a bareos.Staton.datarobot) withrepo.IsTemplateDir, which is a strictly narrower predicate: it wants.datarobot/answers, or a.datarobot/cliholding something other thanstate.yaml. That consolidation was the right call — the old check treated the stray.datarobot/cli/state.yamlthat older CLI versions scattered outside template directories as proof of a template.But the error text did not move with it. So the users most likely to hit the stricter gate — the ones whose
.datarobotfolder exists and is no longer sufficient — get told:They have one. The message sends them looking for something they already did, and says nothing about the marker actually missing. It affects
dr task list,dr run, and shell completion, since the gate runs first inDiscovery.Discover, ahead of thePreferRootTaskfilefallback.CHANGES
ErrNotInTemplatemessage from the same constants the predicate reads, so it names the real markers and points atdr template setupinstead of leaving the remedy to guesswork.repo.TemplateDetectStateFileName. Thestate.yamlexemption was a bare literal inrepo.IsTemplateDir; hardcoding it a second time in the message would have rebuilt the same drift this PR is fixing, so predicate and message now read one constant.BEFORE / AFTER
Fixture: a directory containing a bare
.datarobot/folder.Before (current
main):After (this PR):
Checked against three fixtures — a bare
.datarobot/, a.datarobot/cli/holding onlystate.yaml, and a bare.datarobot/alongside a committed rootTaskfile.yaml. Output is identical betweenmainand this PR on all three except the message text, which is the intended blast radius: no behavior change, same exit code, same gate.NOTE
There is a separate regression around
dr run, discovered while testing here, but I've split that out and have moved it to CFX-7712.TESTING
Two tests in
internal/task/discovery_test.gopin the text to the predicate:TestFormatDiscoveryErrorNamesRealTemplateMarkers— the message must nameevery marker
repo.IsTemplateDirchecks.TestTemplateMarkersMatchAdvertisedRequirement— the directory shapes themessage advertises must pass the gate, and the two it excludes (a bare
.datarobot, and a.datarobot/cliholding onlystate.yaml) must fail it.Both fail against the previous message. Verified by temporarily restoring the old
text: it trips the
.datarobot/cliandstate.yamlassertions, then passes oncethe fix is back.
task lintclean across all three GOOS. Fulltask testgreen, no races.NOTES
Related: #808 covers the other half of the release review that surfaced this (the
versioning guidance in
releasing.md). Independent of this PR.Worth a reviewer's judgment: naming
state.yamlin user-facing copy leaks adetail most people will not care about. I kept it because without it a user with
a
.datarobot/clifolder has no way to understand why they still fail the check.Happy to drop it if you would rather keep the message shorter.
Note
Low Risk
User-facing error copy and a shared filename constant only; template detection logic is unchanged.
Overview
Fixes the not-in-template error so it matches
repo.IsTemplateDirinstead of telling users a bare.datarobotfolder is enough.FormatDiscoveryErrornow names.datarobot/answersor a.datarobot/clifolder with something other thanstate.yaml, and points users atdr template setup. Thestate.yamlexemption is a sharedTemplateDetectStateFileNameconstant so the message cannot drift from the predicate. Tests pin the copy to those markers and to the directory shapes that pass vs fail the gate. Detection behavior is unchanged.Reviewed by Cursor Bugbot for commit fdcdada. Configure here.