Skip to content

fix: replace bare Option.get in getPortId with descriptive IllegalStateException #4978

Open
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Ma77Ball:fix/getPortId
Open

fix: replace bare Option.get in getPortId with descriptive IllegalStateException #4978
Ma77Ball wants to merge 2 commits intoapache:mainfrom
Ma77Ball:fix/getPortId

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

@Ma77Ball Ma77Ball commented May 7, 2026

What changes were proposed in this PR?

AmberFIFOChannel.getPortId called this.portId.get on an Option[PortIdentity] that defaults to None. Calling getPortId before setPortId threw a bare NoSuchElementException with no message, giving callers no indication of which channel was misconfigured or what setup step was missed.

Replaced .get with .getOrElse(throw new IllegalStateException(...)) so the exception identifies the channel and points the caller at the missing setPortId call.

Any related issues, documentation, discussions?

Closes: #4818

How was this PR tested?

Updated the existing AmberFIFOChannelSpec test that covered this path — it previously asserted NoSuchElementException and now asserts IllegalStateException with message content checks ("portId has not been set" and the channel ID string). All 13 specs pass.

Was this PR authored or co-authored using generative AI tooling?

Co-Authored with Claude Opus 4.7 in compliance with ASF

@Ma77Ball Ma77Ball changed the title throw IllegalStateException with context in getPortId before setPortId fix: replace bare Option.get in getPortId with descriptive IllegalStateException May 7, 2026
@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 7, 2026 08:04
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.68%. Comparing base (16d3c6a) to head (fbefa1a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4978      +/-   ##
============================================
- Coverage     42.69%   42.68%   -0.01%     
  Complexity     2186     2186              
============================================
  Files          1031     1031              
  Lines         38111    38112       +1     
  Branches       4004     4004              
============================================
  Hits          16270    16270              
  Misses        20825    20825              
- Partials       1016     1017       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 16d3c6a
agent-service 33.72% <ø> (ø) Carriedforward from 16d3c6a
amber 43.16% <100.00%> (-0.01%) ⬇️
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 16d3c6a
config-service 0.00% <ø> (ø) Carriedforward from 16d3c6a
file-service 33.24% <ø> (ø) Carriedforward from 16d3c6a
frontend 33.00% <ø> (ø) Carriedforward from 16d3c6a
python 88.87% <ø> (ø) Carriedforward from 16d3c6a
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 16d3c6a

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

AmberFIFOChannel.getPortId throws NoSuchElementException when called before setPortId

3 participants