Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle bad input in Args and BusyWorker components #24

Merged
merged 1 commit into from
Jun 29, 2022
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
2 changes: 1 addition & 1 deletion webui/internal/assets/assets.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webui/internal/assets/build/work.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions webui/internal/assets/src/Args.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export default class Args extends React.Component {
render() {
let args = this.props.args;

if (args == null) {
return (
<span>null</span>
);
}

// If object has base64 encoded JSON property named 'payload', try to unwrap it.
if (args.hasOwnProperty('payload') && base64regex.test(args.payload)) {
try {
Expand Down
14 changes: 13 additions & 1 deletion webui/internal/assets/src/Processes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ class BusyWorkers extends React.Component {
worker: PropTypes.arrayOf(PropTypes.object).isRequired,
}

parseJson(input) {
if (input.length === 0) {
return null;
}

try {
return JSON.parse(input);
} catch (e) {
return {parse_error: 'not a valid JSON', value: input};
}
}

render() {
return (
<div className={styles.tableResponsive}>
Expand All @@ -28,7 +40,7 @@ class BusyWorkers extends React.Component {
return (
<tr key={worker.worker_id}>
<td>{worker.job_name}</td>
<td><Args args={JSON.parse(worker.args_json)}/></td>
<td><Args args={this.parseJson(worker.args_json)}/></td>
<td><UnixTime ts={worker.started_at}/></td>
<td><UnixTime ts={worker.checkin_at}/></td>
<td>{worker.checkin}</td>
Expand Down