Skip to content

fix(nanno): guard against mismatched array lengths in extractFieldsFromRecord#401

Merged
holmeso merged 2 commits intonanno_multi_genefrom
copilot/sub-pr-400
Feb 27, 2026
Merged

fix(nanno): guard against mismatched array lengths in extractFieldsFromRecord#401
holmeso merged 2 commits intonanno_multi_genefrom
copilot/sub-pr-400

Conversation

Copy link

Copilot AI commented Feb 27, 2026

extractFieldsFromRecord iterated over fieldNames.length while indexing into fieldPositions[i], causing ArrayIndexOutOfBoundsException when the two arrays had different lengths.

Changes

  • AnnotationSourceTSV.java: Change loop bound from fieldNames.length to Math.min(fieldNames.length, fieldPositions.length), safely processing only the overlapping entries.
// Before
for (int i = 0; i < fieldNames.length; i++) {

// After
for (int i = 0; i < Math.min(fieldNames.length, fieldPositions.length); i++) {
  • AnnotationSourceTSVTest.java: Add test cases for both mismatch directions — fieldNames longer than fieldPositions and vice versa.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit tests added in AnnotationSourceTSVTest.extractFieldsFromRecord() covering both mismatch directions (more names than positions, more positions than names).

Are WDL Updates Required?

No.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: holmeso <7066552+holmeso@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP to address review feedback on pull request #400 fix(nanno): guard against mismatched array lengths in extractFieldsFromRecord Feb 27, 2026
@holmeso holmeso marked this pull request as ready for review February 27, 2026 07:33
@holmeso holmeso merged commit 6f724e2 into nanno_multi_gene Feb 27, 2026
1 check passed
@holmeso holmeso deleted the copilot/sub-pr-400 branch February 27, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants