linslee75 opened a new pull request, #5305:
URL: https://github.com/apache/solr/pull/5305

   https://issues.apache.org/jira/browse/SOLR-18627
   
   Dev list: subject "ignored fields throw NPE since Solr 10.1"
   
   ## Description
   
   Writing a document that contains an ignored field works on Solr 10.0 and 
throws a NullPointerException on 10.1. The whole update is rejected with 400, 
not just the ignored field.
   
   The demo config has dynamicField ignored_* of type ignored:
   
       curl http://localhost:8983/solr/demo/update/json/docs \
         -H 'Content-Type: application/json' \
         -d '{"id":"test","ignored_field":"foobar"}'
   
   Solr 10.0 returns status 0. Solr 10.1 returns status 400.
   
   This was reported on users@:
   https://lists.apache.org/thread.html/28pqz7gkvr3tb3mrj7f9npvs8f6slqq5
   
   David Smiley confirmed on dev@ that this is not the expected behavior, and 
that a test is missing.
   
   ## Cause
   
   ignored is a StrField that is not indexed, not stored, and has no docValues. 
FieldType.createField() returns null for that case, and DocumentBuilder already 
skips null fields.
   
   StrField.createFields() used to return Collections.singletonList(fval), 
which accepts null. Since 10.1 it returns List.of(fval), which does not. The 
NPE is thrown before the field is dropped.
   
   ## Fix
   
   Return an empty list when fval is null, matching FieldType.createFields().
   
   ## Tests
   
   - StrFieldTest.testIgnoredFieldCanBeWritten: an ignored field (not indexed, 
not stored, no docValues) can be passed to createFields without throwing.
   
   AI disclosure: I used an AI coding assistant for the investigation and this 
description. I reviewed and verified the change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to