3636import io .a2a .spec .GetTaskPushNotificationConfigParams ;
3737import io .a2a .spec .HTTPAuthSecurityScheme ;
3838import io .a2a .spec .ImplicitOAuthFlow ;
39+ import io .a2a .spec .InvalidParamsError ;
40+ import io .a2a .spec .InvalidRequestError ;
3941import io .a2a .spec .ListTaskPushNotificationConfigParams ;
4042import io .a2a .spec .Message ;
4143import io .a2a .spec .MessageSendConfiguration ;
@@ -790,6 +792,9 @@ public static Task task(io.a2a.grpc.Task task) {
790792 }
791793
792794 public static Message message (io .a2a .grpc .Message message ) {
795+ if (message .getMessageId ().isEmpty ()) {
796+ throw new InvalidParamsError ();
797+ }
793798 return new Message (
794799 role (message .getRole ()),
795800 message .getContentList ().stream ().map (item -> part (item )).collect (Collectors .toList ()),
@@ -840,7 +845,7 @@ private static Part<?> part(io.a2a.grpc.Part part) {
840845 } else if (part .hasData ()) {
841846 return dataPart (part .getData ());
842847 }
843- return null ;
848+ throw new InvalidRequestError () ;
844849 }
845850
846851 private static TextPart textPart (String text ) {
@@ -853,7 +858,7 @@ private static FilePart filePart(io.a2a.grpc.FilePart filePart) {
853858 } else if (filePart .hasFileWithUri ()) {
854859 return new FilePart (new FileWithUri (filePart .getMimeType (), null , filePart .getFileWithUri ()));
855860 }
856- return null ;
861+ throw new InvalidRequestError () ;
857862 }
858863
859864 private static DataPart dataPart (io .a2a .grpc .DataPart dataPart ) {
@@ -878,7 +883,7 @@ private static Message.Role role(io.a2a.grpc.Role role) {
878883 case ROLE_AGENT ->
879884 Message .Role .AGENT ;
880885 default ->
881- null ;
886+ throw new InvalidRequestError () ;
882887 };
883888 }
884889
@@ -934,7 +939,7 @@ private static Object value(Value value) {
934939 return value .getStringValue ();
935940 case NULL_VALUE :
936941 default :
937- return null ;
942+ throw new InvalidRequestError () ;
938943 }
939944 }
940945 }
0 commit comments