Repository navigation
skills read: end flags before a leading-hyphen file name - #8121
Conversation
`skills read` printed `databricks skills read-file <name> <path>` for each supporting file. A name or path that starts with "-" was read by Cobra as a flag when the agent ran the printed command. Print "--" before the arguments when the name or the file starts with "-". Ordinary names print as before. Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/skills/read: branch ✅ | main (4c4f104) ❌ | latest (v1.28.0) ❌main (4c4f104): latest (v1.28.0): |
✅ Integration test reportCommit: e73a6a0
Top 6 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at 4243c2a. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR makes skills read print databricks skills read-file -- <name> <path> when the skill name or file path starts with -, so Cobra no longer treats it as an unknown flag. The Go change is correct: the check runs on the raw name and path, unquotable entries are still listed without a command, and other lines print exactly as before. What's left is in the new acceptance test, which doesn't follow the repo's testing rules. It adds a new directory where the existing read test could be extended, it repeats settings the parent test.toml already has, and it uses an inline grep. Its last block also repeats a check the eval block already makes.
Comments outside the changed lines
- [nit]
acceptance/cmd/skills/hyphen/script:65: This block runs the sameread-file -- demo-skill -notes.mdthat theevalblock already ran from the printed line, so it only re-tests Cobra's--handling. Can you drop it, or replace it withmusterr trace $CLI skills read-file demo-skill -notes.mdto record the unknown-flag error this PR works around?
| @@ -0,0 +1,11 @@ | |||
| # The printed read-file command ends the flags, so a file named -notes.md is read. | |||
There was a problem hiding this comment.
[nice to have] acceptance/cmd/skills/read already covers the file commands skills read prints, using the shared release fixture. testing.md asks to extend the existing acceptance directory when coverage overlaps. Can you add a -notes.md file to a skill in acceptance/cmd/skills/release and a case to read/script, instead of adding a new hyphen/ directory with its own manifest and skill?
There was a problem hiding this comment.
Done in 2a5b94f. The separate hyphen/ directory is removed. The -notes.md file now lives in guide-skill in the shared release fixture (listed in its manifest), and the cases are in read/script, so only read/output.txt changed (guide-skill file list and its -o json output). The unit test in read_test.go is unchanged.
|
|
||
| title "the printed command runs as printed and prints the file" | ||
| databricks() { "$CLI" "$@"; } | ||
| line=$($CLI skills read demo-skill | grep -- '-notes.md') |
There was a problem hiding this comment.
[nice to have] testing.md says to use the acceptance/bin/ helpers instead of inline grep pipelines. If the -notes.md line ever goes missing from the output, grep returns nothing and eval "" succeeds silently, so the problem only shows up later as a golden diff. The first trace already records the printed line. Can you drop the grep, or assert the line with contains.py before running it?
There was a problem hiding this comment.
Done in 2a5b94f. The grep pipeline is gone. The script now asserts the printed line with contains.py before it runs it with eval, so a missing line fails at that step rather than as a silent empty eval.
| @@ -0,0 +1,3 @@ | |||
| Cloud = false | |||
There was a problem hiding this comment.
[nit] acceptance/cmd/skills/test.toml already sets Cloud = false and Env.DATABRICKS_SKILLS_PREVIEW = "1", and both are inherited. Only Env.DATABRICKS_SKILLS_DIR needs to stay here.
There was a problem hiding this comment.
Done in 2a5b94f. The hyphen/ directory and its test.toml are removed. The case now runs in read/, which inherits Cloud = false and DATABRICKS_SKILLS_PREVIEW from acceptance/cmd/skills/test.toml, and read/script sets DATABRICKS_SKILLS_DIR.
Move the printed read-file case into the existing read acceptance test, using the shared release fixture, instead of a separate hyphen directory. The printed command is asserted with contains.py before it is run, and the separate test.toml is dropped because the parent directory sets the same variables. Co-authored-by: Isaac <no-reply@databricks.com>
rugpanov
left a comment
There was a problem hiding this comment.
No blocking findings. The new branch in writeReadText checks the raw name and path, so it also works for a value that needs quotes. Lines that do not start with a hyphen print as before.
Risk: LOW. The only production change is a 6-line branch in cmd/skills/read.go. The skills group is hidden and gated by DATABRICKS_SKILLS_PREVIEW. The change has unit and acceptance tests, CI is green, and a revert is simple.
libs/skills/hints.go:52 [nice to have] The help hint prints databricks skills read %s with the raw skill name. CheckManifestPaths accepts a skill name that starts with -. For a skill -foo, the hint prints databricks skills read -foo, and Cobra rejects it as an unknown flag. Add the same -- rule here. As an alternative, reject a leading - in skill names and file path segments in CheckManifestPaths. That covers all printers at once.
| title "A file whose name starts with a hyphen: the printed command ends the flags and runs as printed" | ||
| databricks() { "$CLI" "$@"; } | ||
| line="databricks skills read-file -- guide-skill -notes.md" | ||
| $CLI skills read guide-skill | contains.py " $line" > /dev/null |
There was a problem hiding this comment.
[nit] This line sends the contains.py output to /dev/null. .agents/rules/testing.md says to route noisy output to LOG.<name> instead of /dev/null. Then go test -v shows the checked text when the check fails. Change > /dev/null to > LOG.read.
There was a problem hiding this comment.
Changed in c18cfe7: the check now sends its contains.py output to LOG.read instead of /dev/null, so go test -v shows the text when the check fails.
| assert.Contains(t, out.String(), " databricks skills read-file guide-skill \"references/my guide.md\"\n") | ||
| } | ||
|
|
||
| func TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile(t *testing.T) { |
There was a problem hiding this comment.
[nit] No case uses a leading-hyphen value that also needs quotes, for example -my notes.md. If the check later uses quotedFile or quotedName, all current cases still pass. Add a case with such a file for linux and windows, as TestWriteReadTextQuotesFileCommands does.
There was a problem hiding this comment.
Done in c18cfe7: TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile now covers a leading-hyphen file that needs quotes, -my notes.md, for Linux ('-my notes.md') and Windows ("-my notes.md"). The check uses the raw name and path, so the -- branch is the same for quoted values.
| fmt.Fprintf(&b, " databricks skills read-file %s %s\n", quotedName, quotedFile) | ||
| // A leading "-" would make Cobra read the name or file as a flag, so "--" ends the flags first. | ||
| endOfFlags := "" | ||
| if strings.HasPrefix(name, "-") || strings.HasPrefix(f, "-") { |
There was a problem hiding this comment.
[Question] Did you run the printed databricks skills read-file -- guide-skill -notes.md line in Windows PowerShell 5.1? Windows PowerShell can change native arguments that start with -, and the Windows CI runs the acceptance script in bash. The answer tells if the printed command runs as printed on Windows.
There was a problem hiding this comment.
No, I did not run the printed command in Windows PowerShell 5.1, and this environment has no Windows PowerShell. The Windows CI runs the acceptance script in bash, so it does not cover PowerShell either. The Windows unit test only checks the printed text. This is unverified, and I made no code change for it. The printed form is the one the ticket asks for.
The help footer printed the skill name unquoted, so a skill named with a leading hyphen was read by Cobra as a flag. Print "--" first in that case. Also add a quoted leading-hyphen file case and send the acceptance check's output to LOG.read. Co-authored-by: Isaac <no-reply@databricks.com>
|
Note on the review body item about the help footer ( |
The help footer's leading-hyphen handling moves to the stacked pull request that owns the footer, so this branch no longer changes libs/skills. Co-authored-by: Isaac <no-reply@databricks.com>
…-before Brings in the squash-merged skills read change (#8121). Its acceptance manifest conflicted with this branch's hyphen fixture; the branch side is kept, which adds the -foo skill. Co-authored-by: Isaac <no-reply@databricks.com>
databricks skills readprints adatabricks skills read-file <name> <path>command for each supporting file. A name or path that starts with-was read by Cobra as a flag when an agent ran the printed command, so the file could not be read. This PR prints--before the arguments in that case.Changes
skills readprintsdatabricks skills read-file -- <name> <path>when the skill name or the file path starts with-.read-fileneeds no change: Cobra already treats the arguments after--as positional.Why
A file such as
-notes.mdis listed in the manifest and the manifest checks accept it, but the printed commandread-file guide-skill -notes.mdfails with an unknown flag. Ending the flags with--lets the printed command read the file as printed.Decisions to review
--is printed only when a name or path starts with-, not always. Always printing it would change the output for every skill, and the existing goldens with it. The cost is one extra branch inwriteReadText.Tests
TestWriteReadTextEndsFlagsBeforeLeadingHyphenFilecovers a leading-hyphen file name, a leading-hyphen skill name, and a leading-hyphen file name that also needs quotes (Linux and Windows quoting), and checks that ordinary files on the same line keep their command.acceptance/cmd/skills/readchecks that the printed command for-notes.md(a file in the shared release fixture) appears in the output, then runs it withevaland checks that it prints the file. It also runsread-file -- guide-skill -notes.mddirectly.acceptance/cmd/skills/disabledalready checks that theskillsgroup is not registered whenDATABRICKS_SKILLS_PREVIEWis unset, so the change is behind the guard.go test ./cmd/skills/... ./libs/skills/...andgo test ./acceptance -run TestAccept/cmd/skillspass, and./task fmt-q lint-qis clean.This pull request and its description were written by Isaac.