Conversation
There was a problem hiding this comment.
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
JobExitCodeQueryand parse support forexit_codein 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]) |
There was a problem hiding this comment.
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").
| 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], | |
| ) |
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
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