Skip to content

[batch] Allow filter by exit code#15266

Open
cjllanwarne wants to merge 1 commit intohail-is:mainfrom
cjllanwarne:cjl_filter_exit_code
Open

[batch] Allow filter by exit code#15266
cjllanwarne wants to merge 1 commit intohail-is:mainfrom
cjllanwarne:cjl_filter_exit_code

Conversation

@cjllanwarne
Copy link
Collaborator

Change Description

Fixes #15230

Adds options to filter jobs by exit code

Security Assessment

This change potentially impacts the Hail Batch instance as deployed by Broad Institute in GCP

Impact Rating

  • This change has a low security impact

Impact Description

Updated to SQL queries in analogy to existing query functions. Handles validated user input coerced into a strict integer requirement before use

Appsec Review

  • Required: The impact has been assessed and approved by appsec

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for filtering jobs on the batch details page by exit code, wiring the new filter through the UI query builder and the back-end query parser.

Changes:

  • Add an “Exit Code” field to the job search UI dropdown.
  • Extend the front-end query builder config to support numeric exit code comparisons.
  • Add a new JobExitCodeQuery and parse support for exit_code in query v2.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
batch/batch/front_end/templates/table_search.html Adds “Exit Code” as a selectable job search field.
batch/batch/front_end/static/js/table_search.js Defines operators/placeholder for the new exit_code field.
batch/batch/front_end/query/query_v2.py Extends the v2 job query grammar/parser to recognize exit_code.
batch/batch/front_end/query/query.py Implements JobExitCodeQuery SQL condition using jobs.status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


def query(self) -> Tuple[str, List[int]]:
op = self.operator.to_sql()
return (f'(CAST(JSON_EXTRACT(jobs.status, \'$[0]\') AS SIGNED) {op} %s)', [self.exit_code])
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

JobExitCodeQuery.query assumes jobs.status is a JSON array and extracts "$[0]". That matches BatchFormatVersion.db_status for format_version != 1 (stored as [exit_code, duration]), but for format_version == 1 the DB stores the full status object, so this filter will never match legacy jobs. Consider making the SQL handle both shapes (e.g., branch on batches.format_version or COALESCE between "$[0]" and "$.container_statuses.main.container_status.exit_code").

Suggested change
return (f'(CAST(JSON_EXTRACT(jobs.status, \'$[0]\') AS SIGNED) {op} %s)', [self.exit_code])
return (
f"(CAST(COALESCE(JSON_EXTRACT(jobs.status, '$[0]'), "
f"JSON_EXTRACT(jobs.status, '$.container_statuses.main.container_status.exit_code')) AS SIGNED) {op} %s)",
[self.exit_code],
)

Copilot uses AI. Check for mistakes.
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.

Filter jobs by exit code

1 participant