Skip to content

Commit 870e018

Browse files
Merge pull request #263 from UiPath/fix/pack-validate-params
fix(pack): validate project params
2 parents 76ed9ca + 198bea0 commit 870e018

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/uipath/_cli/cli_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def generate_env_file(target_directory):
2020
click.echo(f"Created {relative_path} file.")
2121
with open(env_path, "w") as f:
2222
f.write("UIPATH_ACCESS_TOKEN=YOUR_TOKEN_HERE\n")
23-
f.write("UIPATH_URL=https://alpha.uipath.com/ACCOUNT_NAME/TENANT_NAME\n")
23+
f.write("UIPATH_URL=https://cloud.uipath.com/ACCOUNT_NAME/TENANT_NAME\n")
2424

2525

2626
def get_user_script(directory: str, entrypoint: Optional[str] = None) -> Optional[str]:

src/uipath/_cli/cli_pack.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,21 @@ def pack_fn(projectName, description, entryPoints, version, authors, directory):
292292
def read_toml_project(file_path: str) -> dict[str, any]:
293293
with open(file_path, "rb") as f:
294294
content = tomllib.load(f)
295+
if "project" not in content:
296+
raise Exception("pyproject.toml is missing the required field: project")
297+
if "name" not in content["project"]:
298+
raise Exception(
299+
"pyproject.toml is missing the required field: project.name"
300+
)
301+
if "description" not in content["project"]:
302+
raise Exception(
303+
"pyproject.toml is missing the required field: project.description"
304+
)
305+
if "version" not in content["project"]:
306+
raise Exception(
307+
"pyproject.toml is missing the required field: project.version"
308+
)
309+
295310
return {
296311
"name": content["project"]["name"],
297312
"description": content["project"]["description"],
@@ -320,6 +335,20 @@ def pack(root):
320335
)
321336
return
322337
config = check_config(root)
338+
if not config["project_name"] or config["project_name"].strip() == "":
339+
raise Exception("Project name cannot be empty")
340+
341+
if not config["description"] or config["description"].strip() == "":
342+
raise Exception("Project description cannot be empty")
343+
344+
invalid_chars = ["&", "<", ">", '"', "'", ";"]
345+
for char in invalid_chars:
346+
if char in config["project_name"]:
347+
raise Exception(f"Project name contains invalid character: '{char}'")
348+
349+
for char in invalid_chars:
350+
if char in config["description"]:
351+
raise Exception(f"Project description contains invalid character: '{char}'")
323352
click.echo(
324353
f"Packaging project {config['project_name']}:{version or config['version']} description {config['description']} authored by {config['authors']}"
325354
)

tests/cli/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_init_env_file_creation(runner: CliRunner, temp_dir: str) -> None:
2323
content = f.read()
2424
assert "UIPATH_ACCESS_TOKEN=YOUR_TOKEN_HERE" in content
2525
assert (
26-
"UIPATH_URL=https://alpha.uipath.com/ACCOUNT_NAME/TENANT_NAME"
26+
"UIPATH_URL=https://cloud.uipath.com/ACCOUNT_NAME/TENANT_NAME"
2727
in content
2828
)
2929

0 commit comments

Comments
 (0)