Skip to content

Commit 86f7d53

Browse files
daguimuclaude
andcommitted
[FLINK-39310][web-ui] Use programArgsList in JSON body instead of program-args query parameter
The Web UI's jar.service.ts was using the deprecated program-args query parameter (string) instead of sending programArgsList (string array) in the JSON request body, which is incompatible with the Flink 2.0 REST API. This change updates both runJob() and getPlan() to: - Send parameters via JSON request body with correct field names matching JarRunRequestBody/JarRequestBody (entryClass, programArgsList, parallelism, savepointPath, allowNonRestoredState) - Parse program arguments string into a string array (programArgsList) with proper handling of quoted arguments - Switch getPlan() from GET with query params to POST with JSON body - Fix pre-existing bug where savepointPath query param was incorrectly set to programArgs value instead of savepointPath - Send parallelism as integer and allowNonRestoredState as boolean to match server-side types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c0bc1e5 commit 86f7d53

2 files changed

Lines changed: 72 additions & 29 deletions

File tree

flink-runtime-web/web-dashboard/src/app/interfaces/jar.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export interface JarList {
2222
error?: boolean;
2323
}
2424

25+
export interface JarPlanRequestBody {
26+
entryClass?: string;
27+
programArgsList?: string[];
28+
parallelism?: number;
29+
}
30+
31+
export interface JarRunRequestBody extends JarPlanRequestBody {
32+
savepointPath?: string;
33+
allowNonRestoredState?: boolean;
34+
}
35+
2536
export interface JarFilesItem {
2637
id: string;
2738
name: string;

flink-runtime-web/web-dashboard/src/app/services/jar.service.ts

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { HttpClient, HttpEvent, HttpParams, HttpRequest } from '@angular/common/http';
19+
import { HttpClient, HttpEvent, HttpRequest } from '@angular/common/http';
2020
import { Injectable } from '@angular/core';
2121
import { Observable, of } from 'rxjs';
2222
import { catchError, map } from 'rxjs/operators';
2323

24-
import { JarList, NodesItemCorrect, Plan, PlanDetail, VerticesLink } from '@flink-runtime-web/interfaces';
24+
import {
25+
JarList,
26+
JarPlanRequestBody,
27+
JarRunRequestBody,
28+
NodesItemCorrect,
29+
Plan,
30+
PlanDetail,
31+
VerticesLink
32+
} from '@flink-runtime-web/interfaces';
2533

2634
import { ConfigService } from './config.service';
2735

@@ -64,40 +72,19 @@ export class JarService {
6472
savepointPath: string,
6573
allowNonRestoredState: string
6674
): Observable<{ jobid: string }> {
67-
const requestParam = { entryClass, parallelism, programArgs, savepointPath, allowNonRestoredState };
68-
let params = new HttpParams();
69-
if (entryClass) {
70-
params = params.append('entry-class', entryClass);
71-
}
72-
if (parallelism) {
73-
params = params.append('parallelism', parallelism);
74-
}
75-
if (programArgs) {
76-
params = params.append('program-args', programArgs);
77-
}
75+
const requestBody: JarRunRequestBody = this.buildBaseRequestBody(entryClass, parallelism, programArgs);
7876
if (savepointPath) {
79-
params = params.append('savepointPath', programArgs);
77+
requestBody.savepointPath = savepointPath;
8078
}
8179
if (allowNonRestoredState) {
82-
params = params.append('allowNonRestoredState', allowNonRestoredState);
80+
requestBody.allowNonRestoredState = true;
8381
}
84-
return this.httpClient.post<{ jobid: string }>(`${this.configService.BASE_URL}/jars/${jarId}/run`, requestParam, {
85-
params
86-
});
82+
return this.httpClient.post<{ jobid: string }>(`${this.configService.BASE_URL}/jars/${jarId}/run`, requestBody);
8783
}
8884

8985
public getPlan(jarId: string, entryClass: string, parallelism: string, programArgs: string): Observable<PlanDetail> {
90-
let params = new HttpParams();
91-
if (entryClass) {
92-
params = params.append('entry-class', entryClass);
93-
}
94-
if (parallelism) {
95-
params = params.append('parallelism', parallelism);
96-
}
97-
if (programArgs) {
98-
params = params.append('program-args', programArgs);
99-
}
100-
return this.httpClient.get<Plan>(`${this.configService.BASE_URL}/jars/${jarId}/plan`, { params }).pipe(
86+
const requestBody: JarPlanRequestBody = this.buildBaseRequestBody(entryClass, parallelism, programArgs);
87+
return this.httpClient.post<Plan>(`${this.configService.BASE_URL}/jars/${jarId}/plan`, requestBody).pipe(
10188
map(data => {
10289
const links: VerticesLink[] = [];
10390
let nodes: NodesItemCorrect[] = [];
@@ -120,4 +107,49 @@ export class JarService {
120107
})
121108
);
122109
}
110+
111+
private buildBaseRequestBody(entryClass: string, parallelism: string, programArgs: string): JarPlanRequestBody {
112+
const requestBody: JarPlanRequestBody = {};
113+
if (entryClass) {
114+
requestBody.entryClass = entryClass;
115+
}
116+
if (parallelism) {
117+
requestBody.parallelism = parseInt(parallelism, 10);
118+
}
119+
if (programArgs) {
120+
requestBody.programArgsList = this.parseArgs(programArgs);
121+
}
122+
return requestBody;
123+
}
124+
125+
private parseArgs(programArgs: string): string[] {
126+
const args: string[] = [];
127+
let current = '';
128+
let inSingleQuote = false;
129+
let inDoubleQuote = false;
130+
let hasQuote = false;
131+
132+
for (let i = 0; i < programArgs.length; i++) {
133+
const char = programArgs[i];
134+
if (char === "'" && !inDoubleQuote) {
135+
inSingleQuote = !inSingleQuote;
136+
hasQuote = true;
137+
} else if (char === '"' && !inSingleQuote) {
138+
inDoubleQuote = !inDoubleQuote;
139+
hasQuote = true;
140+
} else if (char === ' ' && !inSingleQuote && !inDoubleQuote) {
141+
if (current.length > 0 || hasQuote) {
142+
args.push(current);
143+
current = '';
144+
hasQuote = false;
145+
}
146+
} else {
147+
current += char;
148+
}
149+
}
150+
if (current.length > 0 || hasQuote) {
151+
args.push(current);
152+
}
153+
return args;
154+
}
123155
}

0 commit comments

Comments
 (0)