Make profile api client more robust#824
Open
zetter-rpf wants to merge 3 commits into
Open
Conversation
Test coverage91.13% line coverage reported by SimpleCov. |
This isn't used anywhere and makes the code brittle as it will fail if new attributes are added to profile
It looks like were not using this, so remove it
It's common when developing with APIs to add in new keys to the response if this happens we don't want this code to error.
d80bf88 to
2c57635
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Makes the ProfileApiClient more robust against changes in the upstream profile API by removing unused response struct definitions/methods and ignoring unexpected keys in student responses.
Changes:
- Remove unused
SchoolandSafeguardingFlagDatastructs and thesafeguarding_flagsmethod, simplifyingcreate_schoolandupdate_school_email_domainsto returntrue. - Filter response keys in
build_studentto only knownStudentmembers so extra keys from the profile API don't raise. - Update specs and the
stub_profile_api_create_schooltest helper to match the new return values and add a regression test for unexpected keys.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/profile_api_client.rb | Drops unused School/SafeguardingFlag structs and safeguarding_flags method; returns true from create_school/update_school_email_domains; slices unknown keys in build_student. |
| spec/lib/profile_api_client_spec.rb | Updates tests to assert true return values, removes the .safeguarding_flags describe block, and adds a test for unexpected keys in student responses. |
| spec/support/profile_api_mock.rb | Simplifies stub_profile_api_create_school to stub a true return and drop the School struct construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PetarSimonovic
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
What's changed?
The error was caused by editor-api erroring when unexpected keys were added in the profile API response.
I think generally JSON APIs should be able to add more attributes without breaking clients.
safeguarding_flagsmethods that aren't usedSee commits for more