Skip to content

Simplify class imports error handling and responses - #1127

Open
zetter-rpf wants to merge 6 commits into
mainfrom
async-import-prep
Open

zetter-rpf wants to merge 6 commits into
mainfrom
async-import-prep

Conversation

@zetter-rpf

@zetter-rpf zetter-rpf commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Status

What's changed?

This is a refactor/simplifying of class imports and the create member class it uses.

To solve https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/2022 I plan on making creating students for imported classes async. To make that easier this:

  • Removes unused response content
  • Removes error states and handling

See commits for more

@cla-bot cla-bot Bot added the cla-signed label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Test coverage

94.17% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/45161243019

@zetter-rpf
zetter-rpf marked this pull request as ready for review November 20, 2026 15:25
@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-async-impo-g0rssu November 20, 2026 15:25 Inactive
@zetter-rpf zetter-rpf changed the title Async import prep Simplify class imports Nov 20, 2026
@zetter-rpf zetter-rpf changed the title Simplify class imports Simplify class imports error handling and responses Nov 20, 2026
@adrian-rpf

Copy link
Copy Markdown
Contributor

@macroscope-app review

@macroscopeapp

macroscopeapp Bot commented Nov 20, 2026

Copy link
Copy Markdown

Manual reviews triggered for commit 3bbe46b:

All prior checks · these links stay valid even if you push more commits.

@macroscopeapp

macroscopeapp Bot commented Nov 20, 2026

Copy link
Copy Markdown

Review started; results will be posted as check runs.

@macroscopeapp

macroscopeapp Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — Class imports stop returning student and membership results, including partial-failure details, while continuing to create rosters. Confirm that current consumers can detect and reconcile incomplete imports without this feedback before removing it.

Needs human approval because:

  • approvability is in preview mode for this repository, so Macroscope does not approve PRs here

You can add or adjust custom eligibility rules. Learn more.

These were just describing the methods on the following line which were already have good names
In the frontend we are ONLY using the `school_class` property so there is no benefit  in returning students and class members. We aren't showing student creation errors either as there are no expected errors to show (but we are reporting them to sentry elsewhere).

I've remove some test cases that cover the response params and updated others to check items are created in the database

As part of this I have also stubbed at a lower level - I think generally feature tests should test as much as possible and only stub external APIs.
There is no point in carrying about these errors as they are never used or displayed.
They are reported to sentry further down the stack.

See previous commit for more
Don't know what these errors are or what we should do in this case. We already have a top level handler for all errors in the API controller.
I've also removed the argument error and changed it so it returns an array - this simplifies callers if they know it always returns the same type of thing.
Things like this are better validated in the controller when data enters your system.

I've added params validation into the controller to catch possible errors sooner

The feature spec that was removed is a bit confusing - it was testing that if no students were found at all it would raise an error.
As far as I can see these are unnecessary as the previous steps always return arrays. I've used casting to ensure the school students param is always an array, and added an early return to the profile API client to save us a HTTP request.
@zetter-rpf
zetter-rpf temporarily deployed to editor-api-p-async-impo-g0rssu November 23, 2026 10:48 Inactive
The class members create operation used for both single and batch operations which have different validation needs. For the single one, we expect an error to be raised if no-one was created, but we don't expect this in the batch operation and aren't handling it.

This branch was successfully deployed

1 active deployment
editor-api-p-async-impo-g0rssu — 5ee43c0f Deployed Nov 23, 2026 by zetter-rpf
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.

4 participants