feat(server): reject resource names that are not RFC 1123 labels - #406
Merged
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
cursor Bot
pushed a commit
to mvanhorn/ax
that referenced
this pull request
Sep 25, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
Member
|
Can you sign the CLA? |
mvanhorn
added a commit
to mvanhorn/ax
that referenced
this pull request
Sep 25, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
ax apply accepted any metadata.name, but Substrate requires actor, ActorTemplate and atespace names to be lowercase RFC 1123 labels. A name such as Task-With-Caps was therefore stored, and only failed seconds later with an asynchronous ActorCreationFailed condition that the user had to dig out of ax describe or the controller logs. Validate metadata.name (and metadata.atespace when set) against [a-z0-9]([-a-z0-9]*[a-z0-9])? with a 63 character limit for Task, Workspace and Model alike, and return InvalidArgument at apply time. Fixes google#370 Co-authored-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
mvanhorn
force-pushed
the
cursor/validate-resource-names-dfaf
branch
from
September 25, 2026 14:52
06fe19f to
46a5012
Compare
Contributor
Author
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.
ax applyaccepted anymetadata.name. Names were only checked when the controller created the SubstrateActorTemplate/Actor, which require a lowercase RFC 1123 label, soTask-With-Capswas stored and then failed seconds later with a confusingActorCreationFailedcondition (and the template error before it is swallowed as a WARN, see #366). This moves the check to apply time.Fixes #370
What changed
pkg/apis/v1alpha1:ValidateName(^[a-z0-9]([-a-z0-9]*[a-z0-9])?$, at most 63 characters, matching Substrate'sk8s-short-name) andValidateObjectMeta, which checksmetadata.nameand, when set,metadata.atespace(it becomes a Substrate atespace name too; empty still defaults todefaultin the server).ValidateTasknow runs it first; newValidateWorkspace/ValidateModeldo the same for the other kinds.internal/server:UpdateWorkspaceandUpdateModelcall the new validators and returnInvalidArgument.UpdateTaskalready goes throughValidateTask, so it needed no change (this also keeps the diff out of the way of Replace UpdateTask with CreateTask and enforce immutability #398).docs/manifests.md: one paragraph on the naming rule.The error is phrased so it is actionable straight from the CLI:
Notes for review:
default/. The shipped examples anddemo.shall use valid names.<task>-tmpl-<8 hex>, so a task name longer than 49 characters still produces a template name over 63. If you'd like, I can cap task names at 49 in a follow-up.How tested
go test ./...(green),go vet ./...,go mod tidyleavesgo.mod/go.sumunchanged.TestValidateName(valid / invalid table incl. 63 vs 64 chars, uppercase,_,., leading / trailing-, whitespace, unicode),TestValidateObjectMeta(name and atespace cases, all three kinds), andinternal/serverTestUpdate_RejectsInvalidNames(Task / Workspace / Model returnInvalidArgument, nothing is persisted, valid names still save). The existingTestValidateTaskfixtures just gained a name.axandax-serverfrom this branch, ranax-serveragainst a local Redis, and applied manifests with an uppercase task name, an underscore workspace name, a dotted atespace, and a valid name (first screenshot).Evidence
Demo
Full-resolution MP4