Skip to content

Configure audiences to log warning on invalid events#553

Closed
codemonium wants to merge 29 commits intomainfrom
JEDI-759
Closed

Configure audiences to log warning on invalid events#553
codemonium wants to merge 29 commits intomainfrom
JEDI-759

Conversation

@codemonium
Copy link
Copy Markdown
Member

This change lets applications that use audiences configure the groups that must be present in a user provisioning event for the event to be considered valid. Some applications do not behave correctly if certain groups are missing.

This change lets applications that use audiences configure the groups
that must be present in a user provisioning event for the event to be
considered valid. Some applications do not behave correctly if certain
groups are missing.
@codemonium codemonium self-assigned this Dec 30, 2025
Copy link
Copy Markdown
Contributor

@gregblake gregblake left a comment

Choose a reason for hiding this comment

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

I think these changes are close to what we need. I added some feedback and questions on comments below.

Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb Outdated
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb Outdated
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb Outdated
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb Outdated
The addition of the required_group_types method caused the ExternalUser
model to be 101 lines. Rubocop is configured to keep classes at a
maximum of 100 lines.

This change extracts the TERRITORY_ABBBRS constant from the ExternalUser
model. This has two benefits: 1) it resolves the Rubocop violation, and
2) it handles territory abbreviations (which could change on a
per-application basis) as application config. No longer hard coding this
value allows apps that use audiences to do customize the TERRITORY_ABBR
data. For example:

```ruby
Audiences.configure do |config|
  config.territory_abbreviations = { "Custom Territory" => "CT" }
end
```
The validation logic now uses ActiveRecord::RecordInvalid.
@gregblake gregblake self-assigned this Jan 6, 2026
@gregblake gregblake marked this pull request as ready for review January 6, 2026 17:23
@gregblake gregblake requested review from a team as code owners January 6, 2026 17:23
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb
Some applications need to subscribe_to this event (for example, to add a
new group to a given criteria).
Comment thread audiences/lib/audiences/scim/upsert_users_observer.rb
@gregblake gregblake changed the title Configure audiences to reject invalid events Configure audiences to log warning on invalid events Jan 19, 2026
@gregblake gregblake requested a review from a team January 19, 2026 22:00
With the changes on this commit, the #process method calls
Audiences.logger.error(e) on any exception, and then raises the
exception. This is consistent with the current behavior on the main
branch, when an actual exception is raised.

Note that the `#valid_group_types?` method still only logs a warning
when there is an user provisioning event where the user is missing one
or more required groups.

Other changes on this commit: #log_upsert_action was extracted from
#process, to keep the Metrics/AbcSize Assignment Branch condition size
under the Rubocop threshold.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 3, 2026

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 24 hours if no further activity occurs.
If this change is desirable, please accelerate completing it. If it is not, please close the PR. If you're blocked on something, please ensure there's a reference to this PR in a story on your team's board so the team will follow up, and consider closing the PR for now.
Please do not artificially extend the deadline with a dummy comment. If necessary, provide a status update, such as "this change is being actively tested".
Thank you for your contributions and your collaboration in reducing WIP and cycle time.

@github-actions github-actions bot added the Stale label Feb 3, 2026
@gregblake gregblake removed the Stale label Feb 6, 2026
@github-actions
Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 24 hours if no further activity occurs.
If this change is desirable, please accelerate completing it. If it is not, please close the PR. If you're blocked on something, please ensure there's a reference to this PR in a story on your team's board so the team will follow up, and consider closing the PR for now.
Please do not artificially extend the deadline with a dummy comment. If necessary, provide a status update, such as "this change is being actively tested".
Thank you for your contributions and your collaboration in reducing WIP and cycle time.

@github-actions github-actions bot added the Stale label Feb 20, 2026
@github-actions github-actions bot closed this Feb 23, 2026
@github-actions github-actions bot deleted the JEDI-759 branch February 23, 2026 21:36
@gregblake gregblake restored the JEDI-759 branch February 23, 2026 21:40
@gregblake gregblake removed the Stale label Feb 23, 2026
@gregblake gregblake reopened this Feb 23, 2026
@github-actions
Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 24 hours if no further activity occurs.
If this change is desirable, please accelerate completing it. If it is not, please close the PR. If you're blocked on something, please ensure there's a reference to this PR in a story on your team's board so the team will follow up, and consider closing the PR for now.
Please do not artificially extend the deadline with a dummy comment. If necessary, provide a status update, such as "this change is being actively tested".
Thank you for your contributions and your collaboration in reducing WIP and cycle time.

@github-actions github-actions bot added the Stale label Mar 10, 2026
@github-actions github-actions bot closed this Mar 13, 2026
@github-actions github-actions bot deleted the JEDI-759 branch March 13, 2026 21:34
@gregblake gregblake restored the JEDI-759 branch March 15, 2026 21:40
@gregblake gregblake reopened this Mar 15, 2026
@gregblake gregblake removed the Stale label Mar 15, 2026
@github-actions
Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 24 hours if no further activity occurs.
If this change is desirable, please accelerate completing it. If it is not, please close the PR. If you're blocked on something, please ensure there's a reference to this PR in a story on your team's board so the team will follow up, and consider closing the PR for now.
Please do not artificially extend the deadline with a dummy comment. If necessary, provide a status update, such as "this change is being actively tested".
Thank you for your contributions and your collaboration in reducing WIP and cycle time.

@github-actions github-actions bot added the Stale label Mar 30, 2026
@github-actions github-actions bot closed this Apr 3, 2026
@github-actions github-actions bot deleted the JEDI-759 branch April 3, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants