Skip to content

fix: remove trailing whitespace from submitcmd#23

Closed
ning-y wants to merge 4 commits intosnakemake:mainfrom
ning-y:remove-trailing-whitespace-submitcmd
Closed

fix: remove trailing whitespace from submitcmd#23
ning-y wants to merge 4 commits intosnakemake:mainfrom
ning-y:remove-trailing-whitespace-submitcmd

Conversation

@ning-y
Copy link
Copy Markdown

@ning-y ning-y commented Aug 13, 2025

This should fix #22: trailing newlines in the submitcmd (provided by the user as cluster-generic-submit-cmd) cause the job submission to fail silently as the trailing newline terminates the command in subprocess.run(..., shell=True) before the job script.

subprocess.check_output(
'{submitcmd} "{jobscript}"'.format(
submitcmd=submitcmd, jobscript=jobscript
),
shell=True,
env=env,
)

Summary by CodeRabbit

  • Bug Fixes
    • Trimmed trailing whitespace from scheduler commands to improve reliability of submissions, status checks, sidecar launches, and cancellations.
    • Applied shell-escaping to submitted scripts and job identifiers to reduce intermittent submission/status/cancellation failures.
    • Improved invocation of cancellation and sidecar commands to avoid quoting and formatting issues with multi-part commands.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 13, 2025

📝 Walkthrough

Walkthrough

Trim trailing whitespace from configured shell commands and shell-escape jobscript and jobids: submit, status, sidecar, and cancel command handling now apply .rstrip() and use shlex.quote() for jobscript/jobid; cancel/sidecar commands are tokenized with shlex.split() before subprocess calls. No public signatures changed.

Changes

Cohort / File(s) Summary
Cluster generic executor core
snakemake_executor_plugin_cluster_generic/__init__.py
Apply .rstrip() to submitcmd, statuscmd, and sidecar_cmd before use; use shlex.quote() for jobscript and external jobid interpolation; convert cancel_cmd and sidecar_cmd to argument lists with shlex.split() for subprocess calls; update join to ",".join(map(str, ...)) for status-kill logging.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Executor as ClusterGenericExecutor
  participant Shell as OS Shell / subprocess

  User->>Executor: run_job(submitcmd, jobscript, env)
  Executor->>Executor: submitcmd_clean = submitcmd.rstrip()
  Executor->>Executor: jobscript_quoted = shlex.quote(jobscript)
  Executor->>Shell: execute submit (clean + quoted jobscript)
  Shell-->>Executor: output (external job id)
  Executor-->>User: record external_jobid

  alt status check
    User->>Executor: check_active_jobs(jobid)
    Executor->>Executor: statuscmd_clean = statuscmd.rstrip()
    Executor->>Executor: jobid_quoted = shlex.quote(jobid)
    Executor->>Shell: execute status (clean + quoted jobid)
    Shell-->>Executor: status output
  end

  alt cancel flow
    User->>Executor: cancel_jobs([jobids])
    Executor->>Executor: cancel_list = shlex.split(cancel_cmd)
    Executor->>Executor: cancel_list.extend(jobids)
    Executor->>Shell: run cancel_list
    Shell-->>Executor: result
  end

  alt sidecar launch
    User->>Executor: _launch_sidecar(sidecar_cmd)
    Executor->>Executor: sidecar_list = shlex.split(sidecar_cmd.rstrip())
    Executor->>Shell: Popen(sidecar_list)
    Shell-->>Executor: sidecar process
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Handle trailing newline in cluster-generic-submit-cmd to ensure jobs submit correctly (#22)
Ensure status commands tolerate trailing whitespace and properly handle jobids (#22)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Tokenize cancel command with shlex.split(self.workflow.executor_settings.cancel_cmd) (snakemake_executor_plugin_cluster_generic/__init__.py, cancel_jobs) Not mentioned in issue #22; changes how cancel command arguments are constructed beyond trimming/escaping submit/status.
Pass sidecar_cmd through shlex.split(... ) to Popen (snakemake_executor_plugin_cluster_generic/__init__.py, _launch_sidecar) Not specified in issue #22; alters sidecar subprocess invocation style beyond fixing trailing whitespace in submit/status.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ning-y ning-y marked this pull request as ready for review August 13, 2025 02:27
@ning-y
Copy link
Copy Markdown
Author

ning-y commented Aug 13, 2025

I've tested that this works using pipenv:

python3 -m pipenv install git+https://github.com/snakemake/snakemake git+https://github.com/ning-y/snakemake-executor-plugin-cluster-generic@remove-trailing-whitespace-submitcmd
python3 -m pipenv shell
which snakemake
# ~/.local/share/virtualenvs/remove-trailing-whitespace-submitcmd-9AOueKMF/bin/snakemake
snakemake --profile .# Using profile . for setting default command line arguments.
# host: login-10-03
# Building DAG of jobs...
# Using shell: /usr/bin/bash
# Provided remote nodes: 1
# Job stats:
# job      count
# -----  -------
# all          1
# total        1
# 
# Select jobs to execute...
# Execute 1 jobs...
# 
# [Wed Aug 13 10:27:06 2025]
# rule all:
#     output: a.txt
#     jobid: 0
#     reason: Missing output files: a.txt
#     resources: mem_mb=4000, mem_mib=3815, disk_mb=50000, disk_mib=47684, tmpdir=<TBD>, queue=workq, walltime=00:05:00, threads=1
# Submitted job 0 with external jobid '256125.hn-10-03'.
# Waiting at most 5 seconds for missing files:
# a.txt (missing locally)
# [Wed Aug 13 10:27:17 2025]
# Finished jobid: 0 (Rule: all)
# 1 of 1 steps (100%) done
# which snakemake
# Complete log(s): /data/wanglf/home/e0175719/repos/remove-trailing-whitespace-submitcmd/.snakemake/log/2025-08-13T102706.130738.snakemake.log

Where the Snakefile was,

rule all:
    output: a = "a.txt"
    shell: "touch {output.a}"

And the config.yaml was,

jobs: 1
executor: cluster-generic
cluster-generic-submit-cmd: >
  qsub \
    -q {resources.queue} \
    -l select=1:ncpus={threads}:mem={resources.mem_mb}mb \
    -l walltime={resources.walltime}
default-resources:
  - queue=workq
  - mem_mb=4000
  - walltime=00:05:00
  - threads=1

@ning-y ning-y changed the title Remove trailing whitespace from submitcmd fix: remove trailing whitespace from submitcmd Aug 13, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (3)
snakemake_executor_plugin_cluster_generic/__init__.py (3)

201-206: Apply the same trailing-whitespace trim to status_cmd to avoid analogous failures.

A trailing newline in status_cmd will also break the shell invocation (the jobid ends up on a new line and is not passed to the status command).

Apply this diff:

-                    ret = subprocess.check_output(
-                        "{statuscmd} '{jobid}'".format(
-                            jobid=job_info.external_jobid,
-                            statuscmd=self.workflow.executor_settings.status_cmd,
-                        ),
+                    ret = subprocess.check_output(
+                        "{statuscmd} '{jobid}'".format(
+                            jobid=job_info.external_jobid,
+                            statuscmd=self.workflow.executor_settings.status_cmd.rstrip(),
+                        ),

301-305: Trim cancel_cmd as well to prevent command-not-found errors when trailing whitespace is present.

With shell=False, a newline or trailing spaces become part of the executable name and will fail to execute.

Apply this diff:

-                    subprocess.check_call(
-                        [self.workflow.executor_settings.cancel_cmd] + chunk,
+                    subprocess.check_call(
+                        [self.workflow.executor_settings.cancel_cmd.rstrip()] + chunk,

371-376: Trim sidecar_cmd to avoid failures when trailing whitespace is present.

With shell=False and a string arg, trailing whitespace becomes part of the program path.

Apply this diff:

-        process = subprocess.Popen(
-            self.workflow.executor_settings.sidecar_cmd,
+        process = subprocess.Popen(
+            self.workflow.executor_settings.sidecar_cmd.rstrip(),
             stdout=subprocess.PIPE,
             shell=False,
             encoding="utf-8",
         )
🧹 Nitpick comments (1)
snakemake_executor_plugin_cluster_generic/__init__.py (1)

153-156: Harden quoting of the jobscript argument to avoid shell expansions and edge cases.

Double quotes allow shell expansions (e.g., $(), backticks) if they ever appear in the path. shlex.quote ensures the path is passed literally and also handles spaces safely.

Apply this diff:

-                    '{submitcmd} "{jobscript}"'.format(
-                        submitcmd=submitcmd.rstrip(), jobscript=jobscript
-                    ),
+                    '{submitcmd} {jobscript}'.format(
+                        submitcmd=submitcmd.rstrip(), jobscript=shlex.quote(jobscript)
+                    ),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce5fc82 and 706952e.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_cluster_generic/__init__.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • snakemake_executor_plugin_cluster_generic/__init__.py
🔇 Additional comments (1)
snakemake_executor_plugin_cluster_generic/__init__.py (1)

152-156: Good fix: trimming trailing whitespace from submitcmd avoids silent job submission failures.

Using submitcmd.rstrip() directly where the shell command is built precisely addresses the issue described in the PR and prevents the shell from treating a trailing newline as command termination.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
snakemake_executor_plugin_cluster_generic/__init__.py (1)

151-158: Fix double-quoting of jobscript (breaks submission).

You’re passing shlex.quote(jobscript) into a format string that already wraps it with double quotes, resulting in an argument that literally contains single quotes around the path. With shell=True, this produces a single argument value like '/path/script.sh' (quotes included), which will likely break submitters expecting a plain path. Drop the outer quotes and rely on shlex.quote.

Apply this diff:

-                    '{submitcmd} "{jobscript}"'.format(
-                        submitcmd=submitcmd.rstrip(), jobscript=shlex.quote(jobscript)
-                    ),
+                    '{submitcmd} {jobscript}'.format(
+                        submitcmd=submitcmd.rstrip(), jobscript=shlex.quote(jobscript)
+                    ),
🧹 Nitpick comments (3)
snakemake_executor_plugin_cluster_generic/__init__.py (3)

201-206: Use shlex.quote for jobid instead of manual single quotes.

Manual single quotes won’t escape embedded single quotes (rare but possible), and it’s inconsistent with the submit path. Prefer shlex.quote and remove the surrounding quotes.

Apply this diff:

-                    ret = subprocess.check_output(
-                        "{statuscmd} '{jobid}'".format(
-                            jobid=job_info.external_jobid,
-                            statuscmd=self.workflow.executor_settings.status_cmd.rstrip(),
-                        ),
+                    ret = subprocess.check_output(
+                        "{statuscmd} {jobid}".format(
+                            jobid=shlex.quote(job_info.external_jobid),
+                            statuscmd=self.workflow.executor_settings.status_cmd.rstrip(),
+                        ),

300-305: Nit: split cancel_cmd into argv when shell=False.

When shell=False, passing a single string with spaces as argv[0] will fail if cancel_cmd contains arguments (e.g., "scancel -p queue"). Using shlex.split is safer while preserving your rstrip() fix.

Apply this diff:

-                    subprocess.check_call(
-                        [self.workflow.executor_settings.cancel_cmd.rstrip()] + chunk,
+                    subprocess.check_call(
+                        shlex.split(self.workflow.executor_settings.cancel_cmd.rstrip()) + chunk,
                         shell=False,
                         timeout=cancel_timeout,
                         env=env,
                     )

370-376: Nit: split sidecar_cmd into argv when shell=False.

Similar to cancel_cmd: with shell=False, a string with spaces is treated as a single executable name. Split the command string to support arguments.

Apply this diff:

-        process = subprocess.Popen(
-            self.workflow.executor_settings.sidecar_cmd.rstrip(),
+        process = subprocess.Popen(
+            shlex.split(self.workflow.executor_settings.sidecar_cmd.rstrip()),
             stdout=subprocess.PIPE,
             shell=False,
             encoding="utf-8",
         )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 706952e and 48b9210.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_cluster_generic/__init__.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • snakemake_executor_plugin_cluster_generic/__init__.py

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
snakemake_executor_plugin_cluster_generic/__init__.py (2)

153-155: Fix is correct: trimming submit_cmd and quoting jobscript prevents silent submits with trailing newlines

This directly addresses issue #22. Using submitcmd.rstrip() and shlex.quote(jobscript) is the right mitigation for the reported failure mode.

One subtle edge case to consider: if users end their submit_cmd with a line-continuation backslash, rstrip() will remove the newline and the trailing backslash will escape the inserted space before {jobscript}, accidentally concatenating the jobscript path to the previous token. To guard against that, prefer inserting a newline when the cleaned submit_cmd ends with a backslash.

Proposed minimal change:

-                    '{submitcmd} {jobscript}'.format(
-                        submitcmd=submitcmd.rstrip(), jobscript=shlex.quote(jobscript)
-                    ),
+                    (
+                        f"{submitcmd.rstrip()}{'\n' if submitcmd.rstrip().endswith('\\') else ' '}"
+                        f"{shlex.quote(jobscript)}"
+                    ),

Follow-up:

  • Please verify behavior with a submit_cmd that intentionally ends with a trailing backslash (line continuation) to ensure it still works as intended.
  • If you’d prefer a clearer implementation, I can refactor this into local variables above the call site for readability. Want me to push that?

225-227: Bug: joining integers in status_cmd_kills causes a TypeError

",".join(self.status_cmd_kills) will raise at runtime because list items are ints. Low-impact and unrelated to this PR, but an easy correctness fix.

Apply:

-                                    ",".join(self.status_cmd_kills),
+                                    ",".join(map(str, self.status_cmd_kills)),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 48b9210 and 0246895.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_cluster_generic/__init__.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • snakemake_executor_plugin_cluster_generic/__init__.py
🔇 Additional comments (3)
snakemake_executor_plugin_cluster_generic/__init__.py (3)

202-205: Good hardening: rstrip() on status_cmd and quoting jobid

Applying .rstrip() to status_cmd and shlex.quote() to the jobid is a solid improvement (avoids the same trailing-whitespace trap and closes injection holes via job IDs).

Please confirm that existing custom status commands do not rely on a trailing newline for behavior (unlikely), and that quoting the jobid does not break any status scripts that expect unquoted job IDs.


302-302: Safer invocation for cancel_cmd via shlex.split + shell=False

This is a good security and robustness improvement. It also naturally ignores trailing whitespace.

This changes semantics if users previously relied on shell features (pipes, redirections) in --cluster-cancel. If that’s not officially supported (it probably shouldn’t be), we’re fine. Otherwise, please document that cancel_cmd must be a single executable with arguments (no shell composition), or add a backward-compatibility note in the README.


372-372: Sidecar command: switch to argv form (shlex.split) is sensible

Running the sidecar with shell=False and a tokenized argv is more predictable and avoids the newline issue.

As with cancel_cmd, this breaks configurations that used shell constructs in sidecar_cmd. If that’s unsupported, consider clarifying in help text/README that sidecar_cmd must be a plain command path plus args.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
snakemake_executor_plugin_cluster_generic/__init__.py (3)

159-161: Prefer splitlines() for platform-agnostic line splitting

Using .splitlines() handles both LF and CRLF without leaving stray carriage returns.

Apply this diff:

-                .decode()
-                .split("\n")
+                .decode()
+                .splitlines()

302-303: Potential backward-compat concern: cancel_cmd now runs without a shell

Switching to shell=False with shlex.split() is safer, but will break configurations that rely on shell metacharacters (pipes, redirections, env var expansion, etc.) inside --cluster-cancel. If users have such commands configured, cancellations may silently fail to execute as intended.

Two options:

  • Keep current behavior but document that cancel_cmd must be a plain executable + args (no shell metachars).
  • Or add a small fallback: detect shell metachars and use shell=True only in that case (still quoting job IDs).

Proposed minimal fallback within this block:

-                    subprocess.check_call(
-                        shlex.split(self.workflow.executor_settings.cancel_cmd) + chunk,
-                        shell=False,
-                        timeout=cancel_timeout,
-                        env=env,
-                    )
+                    cmd_str = self.workflow.executor_settings.cancel_cmd.rstrip()
+                    # Use shell only if the command appears to need it (pipes, redirects, etc.).
+                    if any(ch in cmd_str for ch in "|&;<>()$`\\\"' \n*?[]#~=%"):
+                        cmd = "{} {}".format(
+                            cmd_str, " ".join(shlex.quote(j) for j in chunk)
+                        )
+                        subprocess.check_call(
+                            cmd, shell=True, timeout=cancel_timeout, env=env
+                        )
+                    else:
+                        subprocess.check_call(
+                            shlex.split(cmd_str) + chunk,
+                            shell=False,
+                            timeout=cancel_timeout,
+                            env=env,
+                        )

372-372: Sidecar invocation now uses shell=False — verify commands that rely on shell features

shlex.split(...), shell=False is the right default for safety and correctness, but any sidecar_cmd that includes shell constructs (pipes, redirects, env expansion) will no longer work.

If you need to maintain compatibility with such configurations, add a similar conditional fallback:

-        process = subprocess.Popen(
-            shlex.split(self.workflow.executor_settings.sidecar_cmd),
-            stdout=subprocess.PIPE,
-            shell=False,
-            encoding="utf-8",
-        )
+        cmd_str = self.workflow.executor_settings.sidecar_cmd.rstrip()
+        use_shell = any(ch in cmd_str for ch in "|&;<>()$`\\\"' \n*?[]#~=%")
+        process = subprocess.Popen(
+            cmd_str if use_shell else shlex.split(cmd_str),
+            stdout=subprocess.PIPE,
+            shell=use_shell,
+            encoding="utf-8",
+        )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0246895 and b9fec1d.

📒 Files selected for processing (1)
  • snakemake_executor_plugin_cluster_generic/__init__.py (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • snakemake_executor_plugin_cluster_generic/__init__.py
🔇 Additional comments (3)
snakemake_executor_plugin_cluster_generic/__init__.py (3)

153-155: Trailing-whitespace fix and safer jobscript quoting — good change

Using submitcmd.rstrip() directly addresses the reported failure with trailing newlines, and shlex.quote(jobscript) prevents issues with spaces/special chars in the jobscript path while preserving shell semantics for submitcmd.


202-205: Status command: trimming and quoting are correct

status_cmd.rstrip() removes problematic trailing whitespace and shlex.quote() for jobid avoids injection/word-splitting issues while still allowing complex status_cmd via shell=True.


226-226: Fix join on integers in status_cmd_kills — good catch

",".join(map(str, ...)) prevents TypeError and logs as intended.

@ning-y
Copy link
Copy Markdown
Author

ning-y commented Aug 19, 2025

Now that I look at it again, it is a bit strange that submitcmd and statuscmd are shell-interpreted (shell=True), while cancel_cmd and sidecar_cmd are not (shell=False).

@ning-y ning-y closed this Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cluster-generic-submit-cmd with trailing newlines fail to submit jobs

1 participant