Skip to content

SOLR-16341: fix blank file zip handling#4249

Open
epugh wants to merge 5 commits intoapache:mainfrom
epugh:copilot/fix-blank-file-zip-handling
Open

SOLR-16341: fix blank file zip handling#4249
epugh wants to merge 5 commits intoapache:mainfrom
epugh:copilot/fix-blank-file-zip-handling

Conversation

@epugh
Copy link
Copy Markdown
Contributor

@epugh epugh commented Mar 29, 2026

https://issues.apache.org/jira/browse/SOLR-16341

Description

Better handling of the situation of having a blank file in a zip. Slightly on the fence about the value.

Solution

I don't love how much detailed code is in createTempZipWithStoredEntryAndExtDescriptor, but I guess it's okay.

Here is the output now:

  sample_techproducts_configs git:(copilot/fix-blank-file-zip-handling) zip -r - * | curl -X POST --header "Content-Type:application/octet-stream" --data-binary @- "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=c5"
  adding: conf/ (stored 0%)
  adding: conf/blank.txt (stored 0%)
  adding: conf/update-script.js (deflated 51%)
  adding: conf/elevate.xml (deflated 47%)
  adding: conf/_schema_analysis_synonyms_english.json (deflated 24%)
  adding: conf/mapping-FoldToASCII.txt (deflated 80%)
  adding: conf/params.json (deflated 33%)
  adding: conf/lang/ (stored 0%)
  adding: conf/lang/stopwords_gl.txt (deflated 54%)
  adding: conf/lang/stopwords_es.txt (deflated 67%)
  adding: conf/lang/stopwords_fi.txt (deflated 61%)
  adding: conf/lang/stopwords_da.txt (deflated 59%)
  adding: conf/lang/stopwords_hu.txt (deflated 46%)
  adding: conf/lang/stopwords_id.txt (deflated 62%)
  adding: conf/lang/hyphenations_ga.txt (deflated 14%)
  adding: conf/lang/contractions_it.txt (deflated 33%)
  adding: conf/lang/stopwords_ro.txt (deflated 52%)
  adding: conf/lang/stopwords_eu.txt (deflated 55%)
  adding: conf/lang/stopwords_pt.txt (deflated 65%)
  adding: conf/lang/stopwords_et.txt (deflated 64%)
  adding: conf/lang/stopwords_de.txt (deflated 66%)
  adding: conf/lang/stoptags_ja.txt (deflated 62%)
  adding: conf/lang/stopwords_it.txt (deflated 68%)
  adding: conf/lang/contractions_ca.txt (deflated 19%)
  adding: conf/lang/stopwords_ca.txt (deflated 52%)
  adding: conf/lang/stopwords_th.txt (deflated 59%)
  adding: conf/lang/stopwords_bg.txt (deflated 58%)
  adding: conf/lang/stopwords_lv.txt (deflated 50%)
  adding: conf/lang/userdict_ja.txt (deflated 47%)
  adding: conf/lang/stopwords_ckb.txt (deflated 50%)
  adding: conf/lang/stopwords_cz.txt (deflated 44%)
  adding: conf/lang/stopwords_ar.txt (deflated 48%)
  adding: conf/lang/stopwords_tr.txt (deflated 49%)
  adding: conf/lang/stemdict_nl.txt (deflated 25%)
  adding: conf/lang/stopwords_no.txt (deflated 67%)
  adding: conf/lang/stopwords_nl.txt (deflated 61%)
  adding: conf/lang/stopwords_fa.txt (deflated 56%)
  adding: conf/lang/stopwords_sv.txt (deflated 63%)
  adding: conf/lang/stopwords_el.txt (deflated 53%)
  adding: conf/lang/stopwords_ja.txt (deflated 49%)
  adding: conf/lang/stopwords_hi.txt (deflated 64%)
  adding: conf/lang/stopwords_en.txt (deflated 44%)
  adding: conf/lang/contractions_ga.txt (deflated 15%)
  adding: conf/lang/contractions_fr.txt (deflated 23%)
  adding: conf/lang/stopwords_ru.txt (deflated 65%)
  adding: conf/lang/stopwords_ga.txt (deflated 48%)
  adding: conf/lang/stopwords_fr.txt (deflated 65%)
  adding: conf/lang/stopwords_hy.txt (deflated 44%)
  adding: conf/protwords.txt (deflated 45%)
  adding: conf/_schema_analysis_stopwords_english.json (deflated 64%)
  adding: conf/currency.xml (deflated 62%)
  adding: conf/synonyms.txt (deflated 45%)
  adding: conf/mapping-ISOLatin1Accent.txt (deflated 64%)
  adding: conf/xslt/ (stored 0%)
  adding: conf/xslt/example.xsl (deflated 63%)
  adding: conf/xslt/example_atom.xsl (deflated 55%)
  adding: conf/xslt/luke.xsl (deflated 81%)
  adding: conf/xslt/updateXml.xsl (deflated 59%)
  adding: conf/xslt/example_rss.xsl (deflated 56%)
  adding: conf/managed-schema.xml (deflated 77%)
  adding: conf/spellings.txt (deflated -14%)
  adding: conf/_rest_managed.json (deflated -5%)
  adding: conf/solrconfig.xml (deflated 72%)
  adding: conf/stopwords.txt (deflated 42%)
{
  "responseHeader":{
    "status":400,
    "QTime":11
  },
  "error":{
    "metadata":{
      "error-class":"org.apache.solr.common.SolrException",
      "root-error-class":"java.util.zip.ZipException"
    },
    "errorClass":"org.apache.solr.common.SolrException",
    "msg":"Failed to read the uploaded zip file. The file may be malformed or use an unsupported format. Please recreate the zip file using standard compression tools: only DEFLATED entries can have EXT descriptor",
    "code":400
  }
}% 

Tests

Added a test.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves ConfigSets upload error handling for a ZIP edge case (0‑byte STORED entry using a data descriptor) so the API returns a client error (400) instead of an internal error (500), and adds regression coverage.

Changes:

  • Map ZipException during configset ZIP parsing to SolrException(BAD_REQUEST) in UploadConfigSet.
  • Add a test that uploads a hand-crafted ZIP exhibiting the problematic STORED+EXT/data-descriptor structure and asserts a 400 response.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java Catch ZipException from ZipInputStream while iterating entries and return a 400 with a descriptive error.
solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java Add a regression test that constructs the problematic ZIP variant and verifies the upload returns 400.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

epugh and others added 2 commits March 29, 2026 15:52
…nfigSet.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@epugh
Copy link
Copy Markdown
Contributor Author

epugh commented Mar 31, 2026

I will probably merge this, but I don't love it. A lot of code for a werid situation that I wish just got handled by Java instead!

@epugh
Copy link
Copy Markdown
Contributor Author

epugh commented Mar 31, 2026

@copilot is there a way to properly handle the zero byte file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants