Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cli/lucli/services/packages/PackagesMainCli.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,16 @@ component {
}

private struct function $parseTarget(required string target) {
if (Find("@", arguments.target)) {
local.at = Find("@", arguments.target);
local.at = Find("@", arguments.target);
if (local.at == 1) {
// Target starts with "@" — no name before the pin. Reject cleanly
// rather than crashing on Left(str, 0) (a documented Lucee 7 hazard).
Throw(
type = "Wheels.Packages.BadInput",
message = "Package name is required before '@'. Use: wheels packages install <name>[@<version>]"
);
}
if (local.at > 1) {
return {
name: Left(arguments.target, local.at - 1),
pin: Mid(arguments.target, local.at + 1, Len(arguments.target))
Expand Down
18 changes: 18 additions & 0 deletions cli/lucli/tests/specs/packages/PackagesMainCliSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@ component extends="wheels.wheelstest.system.BaseSpec" {
stack.cache.refresh();
DirectoryDelete(proj, true);
});

it("install throws BadInput when target starts with '@' (empty name)", () => {
// Regression guard: `@1.0.0` used to hit Left(str, 0), which
// crashes on Lucee 7 and produces a cryptic error on other
// engines. Must reject cleanly with BadInput.
var proj = $scratch();
var stack = $buildStack(proj);
var threw = false;
try {
stack.cli.install({target: "@1.0.0"});
} catch (any e) {
threw = true;
expect(e.type).toBe("Wheels.Packages.BadInput");
}
expect(threw).toBeTrue();
stack.cache.refresh();
DirectoryDelete(proj, true);
});
});

describe("PackagesRegistryCli", () => {
Expand Down