@@ -40,9 +40,25 @@ public QdrantOptions(Map<String, String> options) {
4040 Objects .requireNonNull (options );
4141
4242 qdrantUrl = options .get ("qdrant_url" );
43+ if (qdrantUrl == null || qdrantUrl .isEmpty ()) {
44+ throw new IllegalArgumentException ("qdrant_url option is required and cannot be empty" );
45+ }
46+
4347 collectionName = options .get ("collection_name" );
48+ if (collectionName == null || collectionName .isEmpty ()) {
49+ throw new IllegalArgumentException ("collection_name option is required and cannot be empty" );
50+ }
51+
4452 batchSize = getIntOption (options , "batch_size" , DEFAULT_BATCH_SIZE );
53+ if (batchSize <= 0 ) {
54+ throw new IllegalArgumentException ("batch_size must be positive, got: " + batchSize );
55+ }
56+
4557 retries = getIntOption (options , "retries" , DEFAULT_RETRIES );
58+ if (retries < 0 ) {
59+ throw new IllegalArgumentException ("retries cannot be negative, got: " + retries );
60+ }
61+
4662 idField = options .getOrDefault ("id_field" , "" );
4763 apiKey = options .getOrDefault ("api_key" , "" );
4864 embeddingField = options .getOrDefault ("embedding_field" , "" );
@@ -61,22 +77,33 @@ public QdrantOptions(Map<String, String> options) {
6177
6278 validateSparseVectorFields ();
6379 validateVectorFields ();
80+ validateMultiVectorFields ();
6481
6582 payloadFieldsToSkip = buildPayloadFieldsToSkip ();
6683 }
6784
6885 private int getIntOption (Map <String , String > options , String key , int defaultValue ) {
69- return Integer .parseInt (options .getOrDefault (key , String .valueOf (defaultValue )));
86+ String value = options .getOrDefault (key , String .valueOf (defaultValue ));
87+ try {
88+ return Integer .parseInt (value );
89+ } catch (NumberFormatException e ) {
90+ throw new IllegalArgumentException (
91+ "Invalid value for option '" + key + "': '" + value + "'. Expected an integer." , e );
92+ }
7093 }
7194
7295 private boolean getBooleanOption (Map <String , String > options , String key , boolean defaultValue ) {
7396 return Boolean .parseBoolean (options .getOrDefault (key , String .valueOf (defaultValue )));
7497 }
7598
7699 private String [] parseArray (String input ) {
77- return input == null
78- ? new String [0 ]
79- : Arrays .stream (input .split ("," )).map (String ::trim ).toArray (String []::new );
100+ if (input == null || input .trim ().isEmpty ()) {
101+ return new String [0 ];
102+ }
103+ return Arrays .stream (input .split ("," ))
104+ .map (String ::trim )
105+ .filter (s -> !s .isEmpty ())
106+ .toArray (String []::new );
80107 }
81108
82109 private void validateSparseVectorFields () {
@@ -93,6 +120,13 @@ private void validateVectorFields() {
93120 }
94121 }
95122
123+ private void validateMultiVectorFields () {
124+ if (multiVectorFields .length != multiVectorNames .length ) {
125+ throw new IllegalArgumentException (
126+ "Multi vector fields and names should have the same length" );
127+ }
128+ }
129+
96130 private ShardKeySelector parseShardKeys (@ Nullable String shardKeys ) {
97131 if (shardKeys == null ) {
98132 return null ;
0 commit comments