Skip to content

fix(lightspeed): add return statement to address unhandled error in /v1/feedback #3070

Open
Jdubrick wants to merge 3 commits intoredhat-developer:mainfrom
Jdubrick:fix-lightspeed-feedback-error-handling
Open

fix(lightspeed): add return statement to address unhandled error in /v1/feedback #3070
Jdubrick wants to merge 3 commits intoredhat-developer:mainfrom
Jdubrick:fix-lightspeed-feedback-error-handling

Conversation

@Jdubrick
Copy link
Copy Markdown
Contributor

@Jdubrick Jdubrick commented May 7, 2026

Hey, I just made a Pull Request!

✔️ Checklist

Adds a return statement to the /v1/feedback handler when it gets a 500 error, it was the only one missing this out of all the route handlers.

Issue: https://redhat.atlassian.net/browse/RHIDP-13063

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge Bot commented May 7, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented May 7, 2026

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-lightspeed-backend workspaces/lightspeed/plugins/lightspeed-backend patch v2.6.6

@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Fix unhandled error in lightspeed /v1/feedback handler

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Add missing return statement in /v1/feedback error handler
• Prevents unhandled error fallthrough after 500 response
• Add test case for upstream server error handling
Diagram
flowchart LR
  A["POST /v1/feedback"] --> B["Upstream 500 Error"]
  B --> C["Send 500 Response"]
  C --> D["Add return statement"]
  D --> E["Prevent Fallthrough"]
Loading

Grey Divider

File Changes

1. workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts 🐞 Bug fix +2/-0

Add return statement to error handler

• Add return statement after error response in /v1/feedback handler
• Prevents code execution from continuing after error response is sent
• Ensures proper error handling flow for upstream 500 errors

workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.ts


2. workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.test.ts 🧪 Tests +34/-0

Add upstream server error test case

• Add new test case for upstream server error handling
• Mock 500 error response from lightspeed-core server
• Verify proper status code and error message in response

workspaces/lightspeed/plugins/lightspeed-backend/src/service/router.test.ts


3. workspaces/lightspeed/.changeset/shiny-foxes-film.md 📝 Documentation +5/-0

Add changeset for error handler fix

• Create changeset documenting the bug fix
• Mark as patch version bump for lightspeed-backend plugin
• Describe fix for unhandled error in /v1/feedback handler

workspaces/lightspeed/.changeset/shiny-foxes-film.md


Grey Divider

Qodo Logo

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 57.28%. Comparing base (fc38238) to head (2d573c9).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3070   +/-   ##
=======================================
  Coverage   57.28%   57.28%           
=======================================
  Files        2067     2067           
  Lines       63528    63529    +1     
  Branches    16583    16585    +2     
=======================================
+ Hits        36390    36395    +5     
+ Misses      26704    26700    -4     
  Partials      434      434           
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from fc38238
ai-integrations 70.03% <ø> (ø) Carriedforward from fc38238
app-defaults 69.60% <ø> (ø) Carriedforward from fc38238
augment 69.36% <ø> (ø) Carriedforward from fc38238
bulk-import 72.44% <ø> (ø) Carriedforward from fc38238
cost-management 16.49% <ø> (ø) Carriedforward from fc38238
dcm 32.85% <ø> (ø) Carriedforward from fc38238
extensions 61.71% <ø> (ø) Carriedforward from fc38238
global-floating-action-button 73.75% <ø> (ø) Carriedforward from fc38238
global-header 61.68% <ø> (ø) Carriedforward from fc38238
homepage 50.92% <ø> (ø) Carriedforward from fc38238
konflux 91.01% <ø> (ø) Carriedforward from fc38238
lightspeed 70.00% <80.00%> (+0.07%) ⬆️
mcp-integrations 81.59% <ø> (ø) Carriedforward from fc38238
orchestrator 34.80% <ø> (ø) Carriedforward from fc38238
quickstart 62.64% <ø> (ø) Carriedforward from fc38238
sandbox 79.56% <ø> (ø) Carriedforward from fc38238
scorecard 83.61% <ø> (ø) Carriedforward from fc38238
theme 64.54% <ø> (ø) Carriedforward from fc38238
translations 8.49% <ø> (ø) Carriedforward from fc38238
x2a 17.29% <ø> (ø) Carriedforward from fc38238

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


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc38238...2d573c9. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

one question (answers might lead to an actual ask for change)

error: errormsg,
});

return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you didn't touch setting of the status (to 500) above, nor the setting of the status to fetchResponse.status below, but these 2 bits make me ask

  • is fetchResponse.ok false but fetchResponse.status a non error return code ?
  • if fetchResponse.status is an error return code, why do you want to return 500 instead of the upstream error code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think in terms of any error coming from the Lightspeed Core container we are just treating it as 500. The question could be raised to tune this a bit better in the future. wdyt?

for fetchResponse.ok if it is in the 200s it returns true, so we are catching all errors from that check, we could use fetchResponse.status but then we'd need to check for all 2xx codes to say its good I think, .ok is a catch-all for them

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you to convert the various 200s to just 200 I'm ok with that.

But traditionally converting all 300s 400s etc to 500 loses info.

And not sure why we need to wait until the future. What is the concern for addressing these basics now?

Copy link
Copy Markdown
Contributor

@gabemontero gabemontero May 7, 2026

Choose a reason for hiding this comment

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

ok @Jdubrick and I hoped on a quick call ... leaving router.ts change the same, but independent of the issue which drove him to fix things by adding the return, line 529 was non-optimal, and we'll fix that too, where instead of returning 500, we'll use fetchResponse.status

he'll then tweak the unit tests to adjust

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@gabemontero I updated it in this commit b3589db and as part of that fixed the other handlers that were hardcoding 500 as well.

Jdubrick added 3 commits May 7, 2026 16:06
…handled error

Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
@Jdubrick Jdubrick force-pushed the fix-lightspeed-feedback-error-handling branch from b3589db to 2d573c9 Compare May 7, 2026 20:06
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
8.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@Jdubrick Jdubrick requested a review from gabemontero May 7, 2026 20:44
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.

2 participants