Repository navigation
fix(importer): ZIP silently empty, clobbered delimiter, skipped-record resurrection, XML sibling carryover, long-text typed LONG (#6810 #6811 #6812 #6813 #6814) - #6865
Conversation
#6810 - importing any ZIP source silently yielded 0 records. Both reset callbacks in SourceDiscovery called getNextEntry() on the OLD, already closed ZipInputStream instead of the freshly created one, so the new stream was left with no current entry - and a ZipInputStream with no current entry reads as an empty file rather than failing. The reset path runs on every import, and Source.reset() only logged the resulting "Stream closed" IOException, so the import reported success. The new stream is now positioned through the same seek the initial open uses (including the :::<resource> entry, which reset never honoured), and Source.reset() propagates instead of swallowing, so a broken re-open can never again be mistaken for an empty input. The local reset also re-opens through the same file-then-classpath resolution as the first open. #6811 - analyzeSourceContent() unconditionally wrote knownDelimiter into settings.options, but left it null for EntityType.DATABASE. The user's -delimiter / WITH delimiter = ';' lands in that same map, so it was destroyed for every CSV source and the whole line was parsed as a single column, with a property literally named "id;name;age". The put is now guarded, DATABASE reads the generic option back (falling back to -documentsDelimiter), and ';' joins the auto-detection candidate set so a semicolon file without a .csv extension is recognised instead of dying with "Cannot determine the file type". #6812 - createRecord() used one return signal for two opposite outcomes: "no mapping, save this anonymously" and "rejected or deduplicated, drop it". A record the importer had just logged as skipped (duplicate @id without "@strategy": "merge", missing @cat/@type) was therefore saved as an anonymous Document. The anonymous save now happens only when there was no mapping object at all, and a deduplicated @id hands back the existing record so callers link to it. That also removes a latent ClassCastException in convertMap(), which cast an existing (immutable) destination vertex to MutableVertex. #6813 - in the XML importer lastContent was cleared only when a new record started, never when a new sub-element started, so an empty or self-closing sub-element inherited the previous sibling's text, in both the import and the schema-analysis pass. This is the sub-element twin of 2759, which XMLImporterFormatTest fixed for attributes only. State is now cleared on the sub-element boundary; deeper descendants still contribute their text to the property, and an element with no character content becomes an empty property rather than a missing or null one. #6814 - AnalyzedProperty.setLastContent() treated a value longer than 100 chars as "stop sampling" AND as "no evidence about the type", returning before the numeric probes and permanently disabling further analysis of the column. A column whose first value looked numeric was declared LONG, and the import then died converting the very value that should have disproved it. Type refutation now runs on every value, independently of sample collection.
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 8 |
🟢 Coverage 83.15% diff coverage · -6.44% coverage variation
Metric Results Coverage variation ✅ -6.44% coverage variation Diff coverage ✅ 83.15% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (b7c6c80) 167722 134769 80.35% Head commit (dd4c70e) 200138 (+32416) 147922 (+13153) 73.91% (-6.44%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#6865) 89 74 83.15% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe importer now propagates reset failures, reopens and selects source streams correctly, preserves CSV delimiters, filters skipped JSON records, handles empty XML elements, and maintains type-analysis accuracy after sampling limits. Integration tests cover ZIP, CSV, JSON, XML, and long-text scenarios. ChangesImporter regression fixes
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to The importer fixes are merge-ready after normal checks and review; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes address the coding objectives for all linked issues: ZIP stream reset and entry selection, delimiter preservation and semicolon detection, skipped JSON record handling, XML sibling state clearing, and numeric type refutation after sampling limits. Full details: Description checkExplanation The description explains the five defects, motivations, related issues, implementation details, and regression tests. It omits the template headings and checklist, but it is otherwise substantially complete.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
com.arcadedb.utility.Callable.call() declares no checked exception, so the IOException branch was unreachable: both reset callbacks in SourceDiscovery already wrap their IOException into an ImportException. Catching RuntimeException directly says so, and drops the instanceof checks on the caught exception that ErrorProne flagged.
Review of PR #6865Went through both commits ( Correctness - traced through carefully, looks right
Minor observations (non-blocking)
Test coverageFive new test classes, each isolated, each with try/finally cleanup ( Security / dependenciesNo new dependencies. No Nice work - the "same signal used for two different outcomes" root-cause pattern in #6812 and the "early-return doubles as two different meanings" pattern in #6814 are exactly the kind of thing that's easy to introduce and hard to spot without a failing repro, and the fixes address the actual defect rather than papering over symptoms. |
ReviewWent through all five fixes in detail against the surrounding code (not just the diff), traced the data flow for each, and cross-checked the new regression tests against that logic. CorrectnessAll five fixes hold up:
Minor/nit
Test coverageThe five new test classes are well targeted: each pins the specific bug with a guard test for the previously-working path so the fix can't be "tightened" back into a regression, e.g. SecurityNo concerns - no new external input handling, no new dependencies, and the remote-source reset path already goes through Nice work - clear root-cause explanations, minimal targeted diffs, and tests that would have failed on |
|
CI note: the It fails on The lane went red on main somewhere around #6853, which rewrote ~249 lines of Everything this PR does touch is green: all 22 integration-module ITs passed in that same job, including |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6865 +/- ##
==========================================
+ Coverage 71.73% 71.74% +0.01%
==========================================
Files 1878 1878
Lines 167722 167751 +29
Branches 35543 35546 +3
==========================================
+ Hits 120314 120360 +46
+ Misses 32992 32987 -5
+ Partials 14416 14404 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #6810, fixes #6811, fixes #6812, fixes #6813, fixes #6814.
Five independent defects in the importer module, all of which either drop or corrupt imported data without the import ever reporting a failure. Each one has a regression test that was verified to fail against
mainbefore the fix.#6810 - any ZIP source imports as 0 records, reported as success
Both reset callbacks in
SourceDiscoverycalledgetNextEntry()on the old, already closedZipInputStreaminstead of the freshly created one, so the new stream was left with no current entry. AZipInputStreamwith no current entry reads as an empty file rather than throwing, and the reset path runs on every import (Importer.loadFromSource,SourceDiscovery.getSchema,CSVImporterFormat.analyze).Source.reset()only logged the resultingStream closedat SEVERE, so the run finished withTotal documents: 0and no error.Beyond the suggested fix in the issue:
seekZipEntry/positionZipStream, so the:::<resource>entry is honoured on reset too (it never was - reset landed on the first entry of the archive regardless of what the user asked for);Source.reset()propagates instead of swallowing, so a broken re-open can never again be mistaken for an empty input;new FileInputStream(file), which cannot work for the classpath fallback - a latent second way for reset to fail, and one that the newly propagatingreset()would have turned into a hard error.#6811 - the user's delimiter is overwritten with null for every CSV source
analyzeSourceContent()unconditionally wroteknownDelimiterintosettings.options, but left itnullforEntityType.DATABASE. Since-delimiter/WITH delimiter = ';'lands in that same map (ImporterSettings.parseParameter), it was destroyed for every CSV source, andIMPORT DATABASE file://data.csv WITH delimiter = ';'parsed the whole line as one column - producing a property literally namedid;name;age, and reporting success.The put is now guarded, and
case DATABASEreads the generic option back fromsettings.options(falling back to-documentsDelimiter). The guard also means a generic-delimiternow survives for the-documents/-vertices/-edgesforms when no per-entity delimiter is set, instead of being cleared.One addition beyond the issue:
;joins theisSeparator()candidate set. Without it a semicolon-separated file whose extension is not.csvproduced no candidate at all and the import died withCannot determine the file type;;is no more ambiguous than the-and_already in that set, and the best-candidate-by-frequency logic is unchanged.#6812 - a record logged as skipped is saved as an anonymous Document
createRecord()used the same return signal for two opposite outcomes: no mapping, save this anonymously and this record is rejected or deduplicated, drop it.parseRecord()collapsed both intoattributes.map, andparseRecordsArray()then materialized it intosettings.documentTypeName. A duplicate@idwithout"@strategy": "merge", or a mapping object missing@cat/@type- both of which logwill be skippedand incrementcontext.errors- ended up saved anyway.Rather than a sentinel return value, the two cases are separated where the information already exists:
parseRecordsArray()anonymously saves only whenmappingObject == null. That is the one case the anonymous path is meant for, and it deliberately keeps working for the nested"@cat":"e"object, which returns its attribute map on purpose soconvertMap()can turn it into an edge during the mapping phase. Returning a sentinel fromcreateRecord()would have broken exactly that path.@idnow hands the existing record back, so a caller links to it instead of re-materializing the skipped attributes.That second change also fixes a latent
ClassCastExceptionon the same code path:convertMap()cast the destination vertex toMutableVertex, which an existing (immutable) record from the dedup branch could never satisfy. It now goes throughmodify(), a no-op on aMutableVertex.#6813 - an empty or self-closing XML sub-element inherits the previous sibling's value
lastContentwas cleared only when a new record started, never when a new sub-element started, so<rows><row><a>1</a><b></b></row></rows>imported as{a: "1", b: "1"}, in bothload()andanalyze(). This is the sub-element twin of #2759, whose regression test uses attributes exclusively.State is cleared on the sub-element boundary, but only there: the clear at
END_ELEMENTis conditioned on closing the property element itself (nestLevel == objectNestLevel + 2), so a deeper descendant's text still feeds the property and<a><x>1</x><y>2</y></a>keeps its existing last-wins result. The#2759whitespace fix is untouched - whitespace between elements still cannot erase the content of the element currently being read. An element opened and closed with no character content becomes an empty property, which is its XML text content, rather than a missing ornullone.#6814 - a long text value is treated as no evidence, so the column is typed LONG
AnalyzedProperty.setLastContent()treated a value longer than 100 chars as stop sampling and as no evidence about the type, returning before the numeric probes and - becausecollectingSampleswas now permanentlyfalse- making every subsequent value for that column a no-op too. A column whose first value looked numeric was declaredLONGand created as such in the schema, and the import then died on the long value it never examined withCannot convert type 'java.lang.String' to 'LONG'(or, under-onRowError skip, silently dropped every long-text row).Type refutation now runs on every value, independently of sample collection, which covers the
maxValueSamplingshort-circuit the issue also flagged. Sample collection still stops exactly where it did.Tests
Issue6810ZipSourceTest- single-entry and multi-entry (:::nodes.csv) archives.Issue6811CsvDelimiterOptionTest- SQLWITH delimiter, CLI-delimiter,;auto-detection, plus a guard that a plain comma file still imports with no delimiter set.Issue6812JsonSkippedRecordTest- duplicate@id, missing@cat, plus a guard that the legitimate anonymous path still saves.Issue6813XmlEmptySubElementTest- empty and self-closing siblings, plus a guard for nested sub-elements.Issue6814AnalyzedPropertyLongTextTest- unit-level refutation, values after the cut-off, end-to-end CSV import, plus guards that genuinely numeric columns are still typedLONG/DOUBLE.Full
integrationmodule green: 181 unit + 118 integration tests, includingCSVImporterIT,JSONImporterIT,XMLImporterIT,JsonLImporterIT,Neo4jImporterIT,OrientDBImporterITandXMLImporterFormatTest(the #2759 regression).🤖 Generated with Claude Code
https://claude.ai/code/session_01QF6LJaiD6ZRr6oA9WZxVBK
Summary by CodeRabbit
Bug Fixes
Tests