Skip to content

Commit b36c4f6

Browse files
refactor: Resolve most of the open TODOs (#420)
# Description There are currently 4 real TODOs in the codebase: - Usage of `any` in `jsonrpc_transport_handler.ts` - **FIXED** - Snake case and camel case acceptance for `historyLength` - **FIXED** - Stale TODO in cli.ts mentioning exposing protocolName which was already implemented - **TODO REMOVED** - gRPC error mapping should be removed and the errors themselves enriched - **NOT TACKLED, WILL BE DONE IN THE SEPARATE PR**.
1 parent 4bfcf5f commit b36c4f6

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

.betterer.results

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ exports[`TypeScript Strict Mode`] = {
99
[327, 15, 4, "tsc: Expected 2 arguments, but got 1.", "2087764327"],
1010
[350, 15, 4, "tsc: Expected 2 arguments, but got 1.", "2087764327"]
1111
],
12-
"src/server/transports/jsonrpc/jsonrpc_transport_handler.ts:3231104525": [
13-
[91, 12, 10, "tsc: Variable \'rpcRequest\' is used before being assigned.", "3927050741"]
12+
"src/server/transports/jsonrpc/jsonrpc_transport_handler.ts:1878858438": [
13+
[89, 12, 10, "tsc: Variable \'rpcRequest\' is used before being assigned.", "3927050741"]
1414
]
1515
}`
1616
};

src/samples/cli.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ async function fetchAndDisplayAgentCard() {
254254
}
255255
console.log(` Supported Transports: ${Array.from(supportedTransports).join(', ')}`);
256256

257-
// TODO (https://github.com/a2aproject/a2a-js/issues/179): Add a way to get the protocol name from the transport.
258257
console.log(
259258
colorize(
260259
'green',

src/server/express/rest_handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ export function restHandler(options: RestHandlerOptions): RequestHandler {
345345
const result = await restTransportHandler.getTask(
346346
req.params.taskId,
347347
context,
348-
//TODO: clarify for version 1.0.0 the format of the historyLength query parameter, and if history should always be added to the returned object
349-
req.query.historyLength ?? req.query.history_length
348+
req.query.historyLength
350349
);
351350
sendResponse<Task>(res, HTTP_STATUS.OK, context, result, Task);
352351
})

src/server/transports/jsonrpc/jsonrpc_transport_handler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ export class JsonRpcTransportHandler {
6262
* For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
6363
*/
6464
public async handle(
65-
// TODO: remove the eslint disable and replace the any (https://github.com/a2aproject/a2a-js/issues/179)
66-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67-
requestBody: any,
65+
requestBody: string | Record<string, unknown>,
6866
context: ServerCallContext
6967
): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>> {
7068
let rpcRequest: A2ARequest;

test/server/jsonrpc_transport_handler.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ describe('JsonRpcTransportHandler', () => {
5656
});
5757

5858
it('should return an invalid params error for a non-string/non-object request body', async () => {
59-
const response = (await transportHandler.handle(123, defaultContext)) as JSONRPCErrorResponse;
59+
const response = (await transportHandler.handle(
60+
123 as any,
61+
defaultContext
62+
)) as JSONRPCErrorResponse;
6063
expect(response.error.code).to.equal(A2A_ERROR_CODE.INVALID_PARAMS);
6164
expect(response.error.message).to.equal('Invalid request body type.');
6265
});

0 commit comments

Comments
 (0)