GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mail-v2): address the three blocking Major findings from the #1124 review by shazia-k · Pull Request #1132 · OpenResilienceInitiative/ORISO-UserService

Conversation

@shazia-k

@shazia-k shazia-k commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Targets emails-v2 so the fixes land inside PR #1124 rather than alongside it.

Addresses the three findings from the CodeRabbit review on #1124 that block a
pre-dev merge, plus the paired test finding. The other ten Majors are
deliberately untouched — see Not in scope below.

What changed

fix(email) — SMTP rejection replies out of the application log (Major, Security & Privacy)

OrisoEmailDispatcher.send logged the whole SmtpSendException. Its cause chain
is the Jakarta Mail failure, and provider rejection replies routinely embed the
address they rejected (550 5.1.1 <[email protected]> user unknown), so every failed
send wrote an advice-seeker address to disk. NotificationEmailService already
refuses to retain these details for exactly this reason, and
WelcomeEmailService still routes through this call site.

Now logs the exception type chain plus the configured SMTP host — operator
configuration, not personal data — following the getClass().getSimpleName()
convention already used in GlobalSmtpSettingsResolver and
CaseHandoverEmailNotification. Auth failures, TLS failures and timeouts stay
distinguishable. The chain is bounded at five links and tolerates a cyclic cause.

perf(email) — collapse per-recipient tenant branding lookups (Major, Performance & Scalability)

Source 2606d840 switched to getRestrictedTenantDataFresh so a logo change
reaches mail immediately. That fixed the staleness, but resolve() runs once per
recipient: NotificationEmailService.render calls valuesForTenant for every
entry in a batch, so a daily digest of N consultants issues N remote calls to
TenantService, nearly all for the same tenant.

This is not a restoration of the 24-hour cache that was removed. It is a memo
keyed by tenant id with a 10-second default TTL, configurable via
email.branding.cache-ttl-seconds. A branding save is still visible in the next
mail within seconds; one batch costs one lookup. Setting the TTL to 0 disables
it, and the existing five-argument constructor delegates with 0, so current
behaviour and test determinism are preserved. Null results are memoised too (the
tenant-admin invite resolves to "no tenant yet", and repeating that 404 once per
recipient helps nobody). The platform lookup uses its own sentinel key, so no
tenant can be served another tenant's brand.

fix(handover) — isolate policy cache failures per tenant (Major, Stability & Availability, + the test finding)

Two defects in the last-known-good path:

  • refreshKnownTenants ran refresh inside a plain forEach. One tenant whose
    snapshot could not be read aborted the sweep, so every tenant after it was
    never refreshed and silently kept an aging snapshot.
  • Inside refresh, the upstream-failure branch called deserialize, which
    throws IllegalStateException on invalid JSON — escaping the very catch block
    meant to provide the fallback, and surfacing as "Cached Case Handover policy is
    invalid" rather than the real outage. getEffective had the same defect on the
    read path.

Deserialisation now yields an Optional. getEffective refreshes when the
stored snapshot is unreadable; refresh rethrows the original upstream
failure so the real cause stays visible; the scheduled sweep isolates and logs
each tenant. Adds the two cases the review identified as missing.

Why this one is not cosmetic: when the policy read fails, CaseHandoverService
falls back to the legacy reason rows — and on Dev all five of those carry
client_consent_required = 0. A silently skipped refresh is a silently weakened
consent gate.

Verification

Full unit suite on this branch, JDK 21:

Tests run: 4440, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Spotless passes (bound to compile, so a clean build proves formatting).
Testcontainers ITs were not run locally — no Docker on this machine; CI's
Docker validation job covers them.

Reviewer test plan

  • Force an SMTP rejection and confirm the log line carries the host and the
    exception type chain, and no address or reply text.
  • Send a digest batch to several consultants of one tenant; confirm a single
    getRestrictedTenantDataFresh call rather than one per recipient.
  • Save a tenant logo, then trigger a mail within ~10s and confirm the new
    logo appears — the freshness 2606d840 restored must still hold.
  • Corrupt one tenant's tenant_case_handover_policy_cache.policies value and
    confirm the scheduled sweep still refreshes the other tenants.

Not in scope

The remaining ten Majors are untriaged here by agreement: findings 1, 2, 5, 10,
11 and 12 are queued before a dev promotion; 6, 7 and 9 (unbounded queries and
in-memory pagination) are follow-up tickets.

Separately, and not changed here: refreshKnownTenants calls refresh on
this, so Spring's proxy is bypassed and @Transactional never applies on the
scheduled path. Harmless today because the repository methods carry their own
transactions, but it deserves its own ticket rather than a smuggled-in change.

Also still open and a product decision, not a code fix: case_handover_reason_policy
on Dev holds the five legacy codes with client_consent_required = 0 for all of
them. Someone should confirm that is the intended product state before this
reaches an environment where handover is exercised.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Shazia Kausar and others added 3 commits September 9, 2026 08:52
Shazia Kausar @claude
fix(email): keep SMTP rejection replies out of the application log
8484517
OrisoEmailDispatcher.send logged the whole SmtpSendException. Its cause chain
is the Jakarta Mail failure, and provider rejection replies routinely embed the
address they rejected ("550 5.1.1 <[email protected]> user unknown"), so every failed
send wrote an advice-seeker address to disk.

NotificationEmailService already refuses to retain these details for exactly
this reason; this call site contradicted that decision, and WelcomeEmailService
still routes through it.

Log the exception type chain and the configured SMTP host instead - operator
configuration, not personal data. Auth failures, TLS failures and timeouts stay
distinguishable. The chain is bounded at five links and tolerates a cyclic
cause, so a deeply wrapped failure cannot flood the log.

Refs CodeRabbit review on #1124 (Major, Security & Privacy).

Co-Authored-By: Claude Opus 5 <[email protected]>
Shazia Kausar @claude
perf(email): collapse per-recipient tenant branding lookups
d0885ba
Source 2606d84 replaced the cached tenant read with getRestrictedTenantDataFresh
so a logo change reaches mail immediately. That fixed the staleness, but resolve()
runs once per recipient: NotificationEmailService.render calls valuesForTenant for
every entry in a batch, so a daily digest of N consultants now issues N remote
calls to TenantService, plus the platform fallbacks, nearly all for the same
tenant.

Add a short-lived memo keyed by tenant id, default 10 seconds and configurable
via email.branding.cache-ttl-seconds. This is deliberately not the 24-hour cache
that was removed: a branding save is still visible in the next mail within
seconds, while one batch costs one lookup. Setting the TTL to 0 disables it, and
the existing five-argument constructor keeps that behaviour so tests stay
deterministic.

Null results are memoised too - a tenant-admin invite resolves to "no tenant
yet", and repeating that 404 once per recipient helps nobody. Entries are keyed
per tenant with a platform sentinel, so no tenant can be served another's brand.

Refs CodeRabbit review on #1124 (Major, Performance & Scalability).

Co-Authored-By: Claude Opus 5 <[email protected]>
Shazia Kausar @claude
fix(handover): isolate Case Handover policy cache failures per tenant
36691e6
Two defects in the last-known-good path, both of which end with a tenant
enforcing a policy nobody chose.

refreshKnownTenants ran refresh inside a plain forEach. One tenant whose
snapshot could not be read aborted the sweep, so every tenant after it was
never refreshed and silently kept an aging snapshot.

Inside refresh, the upstream-failure branch called deserialize on the persisted
snapshot. deserialize throws IllegalStateException on invalid JSON, so that
exception escaped the very catch block meant to provide the fallback - and it
surfaced as "Cached Case Handover policy is invalid", hiding the real outage.
getEffective had the same defect on the read path, where an unreadable snapshot
threw instead of falling through to a refresh.

Deserialisation now yields an Optional. getEffective refreshes when the stored
snapshot is unreadable; refresh rethrows the ORIGINAL upstream failure so the
real cause stays visible to callers, and the scheduled sweep isolates and logs
each tenant.

This matters beyond robustness: when the policy read fails, CaseHandoverService
falls back to the legacy reason rows, and on Dev all five of those carry
client_consent_required = 0. A silently skipped refresh is therefore a silently
weakened consent gate.

Adds the two cases the production code actually failed on, per the review.

Refs CodeRabbit review on #1124 (Major, Stability & Availability).

Co-Authored-By: Claude Opus 5 <[email protected]>
@shazia-k
shazia-k requested review from Shirloin and Storypapst September 9, 2026 07:20
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • dev

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d3d78d2f-6b30-4bd1-8e36-29a7306e320e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Shazia Kausar @claude
chore(observability): inventory the branding cache as process-local s…
e604796
…tate

The replica-safety contract fails the build for any main source holding
process-local state that the catalogue does not declare, and the ConcurrentHashMap
added in d0885ba is exactly that. The gate is right to stop it: an undeclared
per-replica cache is how scale-out surprises happen.

Declared as bounded/performance, next to the sibling email-template-cache. The
decision text records what makes this one different from that cache: it holds
mutable tenant branding, so replicas CAN disagree - but only inside the TTL, and
a miss re-reads through getRestrictedTenantDataFresh, so no replica serves
branding older than email.branding.cache-ttl-seconds. It also records why the
TTL is short, so nobody later "optimises" it back towards the 24h cache that
2606d84 removed.

Verified: tests/ci/test_replica_safety_contract.py and
ReplicaSafetyInventoryContractTest both pass; full unit suite 4440/0/0/0.

Co-Authored-By: Claude Opus 5 <[email protected]>
@shazia-k
shazia-k merged commit df31f98 into emails-v2 Sep 9, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@shazia-k
shazia-k deleted the fix/mail-v2-coderabbit-majors branch September 9, 2026 07:36
@shazia-k shazia-k mentioned this pull request Sep 9, 2026
fix(mail-v2): close the remaining CodeRabbit findings on #1124 #1133
Merged
5 tasks
shazia-k added a commit that referenced this pull request Sep 9, 2026
@Storypapst @shazia-k
Shazia Kausar @claude
fix: deliver tenant-branded emails and restore shared account recovery (
b5d2a94
#1124)

* fix(email): wire notification SMTP and effective tenant branding

Reuse the installed SMTP transport and existing email layouts for legacy notification producers. Preserve SMTP acceptance semantics, carry tenant branding across async senders, resolve platform assets by actual owner, and retain actively viewed messages as read timeline entries.

Implemented and tested by Codex from Frank Gerhardt's requirements. Local validation: 372 selected regression tests, Spotless, and package passed. No deployment or real-mail acceptance claimed.

* fix(email): retain tenant branding in scheduled notification batches

Carry the owning tenant through existing template metadata for digest and inactivity mail. Render every recipient independently without changing ambient thread context, including mixed-tenant batches.

Implemented and tested by Codex from Frank Gerhardt's requirements. Three regression cases failed before the change; 28 targeted tests, Spotless and package now pass locally. Runtime acceptance remains separate.

* fix(email): honor dedicated enquiry digest preference

Implemented and tested by Codex from Frank Gerhardt’s requirements. NEW_EMAIL_NOTIFICATIONS now combines the master switch with notifyEnquiriesRepeating rather than the initial-enquiry preference. Regression matrix covers both release-toggle modes and independent preference settings. Schedule unchanged.

* fix(auth): preserve reset request tenant across async dispatch

* fix(email): honor assignment notification preferences

Implemented and locally tested by Codex from Frank Gerhardt’s requirements. Modern assignment mail respects the recipient master switch and explicit assignment opt-out; missing or null row retains default-on semantics. Legacy mode remains unchanged. Focused regression matrix covers both gates and defaults; no runtime mail claim.

* fix(email): use transactional layout for operational messages

Implemented and tested by Codex from Frank Gerhardt’s requirements after actual acceptance-mail receipt exposed an invitation CTA. Routes authored operational content through the existing mitteilung design, retains exact subject and sanitized rich/plain body, and uses the platform CTA. Actual invitation rendering is unchanged. Focused tests reproduced the wrong CTA and verify sanitization and MIME content.

* fix(auth): resolve shared password recovery by exact identity tenant

* fix(email): isolate recipient failures and inject shared SMTP resolver

* fix(email): validate branding URLs and normalize default ports

* fix(email): keep SMTP diagnostic links on configured app origin

Default the notification base to app.base.url while retaining its explicit override. Send only the diagnostic primary CTA to /admin while keeping footer links at the application base. Four focused tests and Spotless passed; both origin and CTA regressions failed before the fix. Implemented and verified by OpenAI Codex.

* test(email): verify reassignment through current SMTP delivery boundary

* test: clear registration tenant context between integration tests

The testing profile disables HttpTenantFilter, leaving registration fixture tenant state on the JUnit thread. Clear it before setup and before teardown fixture restoration can fail.

Verified exact CI predecessor sequence: 7 failures before, 136 passing after; full required integration suite: 908 passing, no skips. Spotless passed.

Implemented and verified by OpenAI Codex.

* fix: resolve current tenant branding for outgoing mail

Use the existing uncached tenant lookup for concrete-tenant mail branding so saved logo additions and removals are reflected without the 24-hour tenant cache delay.

Verified regression red before fix; 43 resolver and tenant service/cache tests pass with Spotless. Implemented and tested by OpenAI Codex.

* fix: refresh platform mail branding without tenant cache

The platform branding getter is used only by the mail resolver. Remove its cache annotation while preserving explicit technical tenant scope zero and the main-subdomain lookup; unrelated tenant caches remain unchanged.

Real Spring cache regression fails before and passes after for logo addition/removal, preserving ambient tenant context. 50 resolver, tenant/cache and template supplier tests pass with Spotless. Implemented and verified by OpenAI Codex.

* fix: align invitation delivery and preview with modern mail layout

* fix: exclude removed agencies from consultant profiles

Use the supported ORM collection restriction so profile reloads exclude soft-deleted relations while retaining their audit history. Refs #1125. Regression reproduced before the fix; 38 related database/profile tests pass.

* fix: send tenant system notifications through the secret owner

Refs #1006 and OpenResilienceInitiative/ORISO-TenantService#240. Authenticate explicitly on the asynchronous path and delegate the three existing system-mail purposes without reading SMTP credentials. Preserve recipient privacy and rendering, reject invalid tenants, sanitize failures and close the technical session. Fifty focused tests pass.

* fix: select standard headers in tenant email client

* test: pin current contact email JSON binding contract

* fix(mail): render readable contact login and wrap long values

* fix(handover): preserve department-scoped candidate lookup (#1105)

Integrates existing 9da1c03 candidate-scope slice onto mail-v2 without replacing the current email work. Adapted and verified by OpenAI Codex. Focused regression: 59 tests pass; prior behavior produced 11 failures and 1 error.

* feat(handover): preserve effective policy and temporary co-access semantics

* feat(handover): dispatch takeover outcome mail after commit

* feat(handover): adapt named offers and committed takeover mail outcomes

* test(handover): publish and guard the complete offer and access contract

* fix(handover): retain current owner membership when old co-access expires

* fix(handover): preserve policy and history during schema convergence

* ci: pin handover contracts to coordinated TenantService provider

* ci: assign handover schema preservation to required MariaDB suite

* fix(handover): account for bounded scheduler leases and release tenant context

* test(handover): cover legacy null grants and strict scheduler inventory

* fix(handover): authenticate policy reads and preserve event access type

* fix(mail-v2): address the three blocking Major findings from the #1124 review (#1132)

* fix(email): keep SMTP rejection replies out of the application log

OrisoEmailDispatcher.send logged the whole SmtpSendException. Its cause chain
is the Jakarta Mail failure, and provider rejection replies routinely embed the
address they rejected ("550 5.1.1 <[email protected]> user unknown"), so every failed
send wrote an advice-seeker address to disk.

NotificationEmailService already refuses to retain these details for exactly
this reason; this call site contradicted that decision, and WelcomeEmailService
still routes through it.

Log the exception type chain and the configured SMTP host instead - operator
configuration, not personal data. Auth failures, TLS failures and timeouts stay
distinguishable. The chain is bounded at five links and tolerates a cyclic
cause, so a deeply wrapped failure cannot flood the log.

Refs CodeRabbit review on #1124 (Major, Security & Privacy).

Co-Authored-By: Claude Opus 5 <[email protected]>

* perf(email): collapse per-recipient tenant branding lookups

Source 2606d84 replaced the cached tenant read with getRestrictedTenantDataFresh
so a logo change reaches mail immediately. That fixed the staleness, but resolve()
runs once per recipient: NotificationEmailService.render calls valuesForTenant for
every entry in a batch, so a daily digest of N consultants now issues N remote
calls to TenantService, plus the platform fallbacks, nearly all for the same
tenant.

Add a short-lived memo keyed by tenant id, default 10 seconds and configurable
via email.branding.cache-ttl-seconds. This is deliberately not the 24-hour cache
that was removed: a branding save is still visible in the next mail within
seconds, while one batch costs one lookup. Setting the TTL to 0 disables it, and
the existing five-argument constructor keeps that behaviour so tests stay
deterministic.

Null results are memoised too - a tenant-admin invite resolves to "no tenant
yet", and repeating that 404 once per recipient helps nobody. Entries are keyed
per tenant with a platform sentinel, so no tenant can be served another's brand.

Refs CodeRabbit review on #1124 (Major, Performance & Scalability).

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(handover): isolate Case Handover policy cache failures per tenant

Two defects in the last-known-good path, both of which end with a tenant
enforcing a policy nobody chose.

refreshKnownTenants ran refresh inside a plain forEach. One tenant whose
snapshot could not be read aborted the sweep, so every tenant after it was
never refreshed and silently kept an aging snapshot.

Inside refresh, the upstream-failure branch called deserialize on the persisted
snapshot. deserialize throws IllegalStateException on invalid JSON, so that
exception escaped the very catch block meant to provide the fallback - and it
surfaced as "Cached Case Handover policy is invalid", hiding the real outage.
getEffective had the same defect on the read path, where an unreadable snapshot
threw instead of falling through to a refresh.

Deserialisation now yields an Optional. getEffective refreshes when the stored
snapshot is unreadable; refresh rethrows the ORIGINAL upstream failure so the
real cause stays visible to callers, and the scheduled sweep isolates and logs
each tenant.

This matters beyond robustness: when the policy read fails, CaseHandoverService
falls back to the legacy reason rows, and on Dev all five of those carry
client_consent_required = 0. A silently skipped refresh is therefore a silently
weakened consent gate.

Adds the two cases the production code actually failed on, per the review.

Refs CodeRabbit review on #1124 (Major, Stability & Availability).

Co-Authored-By: Claude Opus 5 <[email protected]>

* chore(observability): inventory the branding cache as process-local state

The replica-safety contract fails the build for any main source holding
process-local state that the catalogue does not declare, and the ConcurrentHashMap
added in d0885ba is exactly that. The gate is right to stop it: an undeclared
per-replica cache is how scale-out surprises happen.

Declared as bounded/performance, next to the sibling email-template-cache. The
decision text records what makes this one different from that cache: it holds
mutable tenant branding, so replicas CAN disagree - but only inside the TTL, and
a miss re-reads through getRestrictedTenantDataFresh, so no replica serves
branding older than email.branding.cache-ttl-seconds. It also records why the
TTL is short, so nobody later "optimises" it back towards the 24h cache that
2606d84 removed.

Verified: tests/ci/test_replica_safety_contract.py and
ReplicaSafetyInventoryContractTest both pass; full unit suite 4440/0/0/0.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Shazia Kausar <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Frank Gerhardt <[email protected]>
Co-authored-by: Shazia Kausar <[email protected]>
Co-authored-by: Shazia Kausar <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
@Shirloin Shirloin mentioned this pull request Oct 6, 2026
Require first-login password change for admin-created accounts #1302
Closed
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Storypapst Storypapst Awaiting requested review from Storypapst
@Shirloin Shirloin Awaiting requested review from Shirloin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@shazia-k
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.