Skip to content

fix: prevent StringIndexOutOfBoundsException in HARImporter for URLs without file extension - #2158

Merged
lbroudoux merged 1 commit into
microcks:masterfrom
Harishrs2006:fix/har-importer-url-no-extension
Jun 9, 2026
Merged

lbroudoux merged 1 commit into
microcks:masterfrom
Harishrs2006:fix/har-importer-url-no-extension

Conversation

@Harishrs2006

Copy link
Copy Markdown
Contributor

Summary

  1. Fixed a crash in HARImporter.filterValidEntries() where URLs with no
    file extension (e.g. /api/users) caused lastIndexOf(".") to return -1,
    making substring(-1) throw StringIndexOutOfBoundsException
    2)Added a guard so extension-less URLs are treated as valid API entries
  2. HAR import no longer fails when any entry has a clean REST URL

Changes
webapp/src/main/java/io/github/microcks/util/har/HARImporter.java line 387

Test plan
[ ] Import a HAR file with a request to /api/users (no extension) should succeed
[ ] Verify existing HAR files with extensions (.ico, .js) still get filtered out

Fixes #2157

@lbroudoux

Copy link
Copy Markdown
Member

Hi @Harishrs2006
This looks good but the DCO check fails. Can you check the details and apply the commands to fix this?
I'll be ready to merge just after.

…without file extension

URLs without a '.' character (e.g. /api/users) caused lastIndexOf('.') to
return -1, making substring(-1) throw StringIndexOutOfBoundsException and
failing the entire HAR import. Guard added to treat extension-less URLs as
valid API entries.

Fixes #<ISSUE_NUMBER>

Signed-off-by: Harishrs2006 <[email protected]>
@Harishrs2006
Harishrs2006 force-pushed the fix/har-importer-url-no-extension branch from 4ce1ca9 to fe73d59 Compare June 9, 2026 14:14
@lbroudoux lbroudoux added this to the 1.15.0 milestone Jun 9, 2026

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you!

@lbroudoux
lbroudoux merged commit 4283136 into microcks:master Jun 9, 2026
11 of 12 checks passed
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🎉 @Harishrs2006

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

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.

bug: HARImporter crashes with StringIndexOutOfBoundsException on URLs with no file extension

2 participants