Skip to content

Fix stale certificate issued state#575

Merged
heisbrot merged 2 commits intomainfrom
fix/stale-certificate-issued
Mar 9, 2026
Merged

Fix stale certificate issued state#575
heisbrot merged 2 commits intomainfrom
fix/stale-certificate-issued

Conversation

@heisbrot
Copy link
Copy Markdown
Contributor

@heisbrot heisbrot commented Mar 4, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved reverse proxy status display to more reliably reflect certificate issuance and service readiness.
    • Refined polling so status checks stop/start based on actual readiness and certificate state.
    • Clarified UI status indicators to consistently show "Issuing certificate..." and "Setting up service..." at the correct times.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Replaces useMemo with useRef to persist fetched data, consolidates activation logic into an isActive flag sourced from meta or dataRef.current, introduces shouldPoll to control polling, and simplifies conditional rendering for certificate issuance and service setup (keeps existing UI branches).

Changes

Cohort / File(s) Summary
Reverse Proxy Status Cell
src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx
Replaced useMemo with useRef for persisted fetch results; introduced dataRef.current access; derived isActive from meta.status or dataRef.current.meta.status; added shouldPoll (enabled, isActive, certificateIssued) passed to useFetchApi; simplified certificate and readiness checks and conditional rendering while preserving "Issuing certificate..." and "Setting up service..." branches.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A ref now cradles the fetched view,
Status aligned, old memos bid adieu,
Polling checks tidy, conditions light and true,
Certificates, setups — the UI hops through!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix stale certificate issued state' directly relates to the main objective of the changeset, which addresses stale state in certificate issuance tracking by replacing useMemo with useRef for persistent fetch result tracking.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/stale-certificate-issued

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx`:
- Around line 34-41: The poll flag currently stops as soon as certificateIssued
is true, which can freeze the UI if the service hasn't reached ACTIVE; fix by
computing shouldPoll using the fetched ReverseProxy status so polling continues
until status === 'ACTIVE'. Concretely, call
useFetchApi(`/reverse-proxies/services/${serviceId}`, ...) with polling enabled,
then compute shouldPoll = !!enabled && ( !certificateIssued || data?.status !==
'ACTIVE' ) (or move the hook so you can derive shouldPoll from data), and pass
that flag (or stop polling only when data.status === 'ACTIVE') so the cell keeps
refreshing until the service becomes ACTIVE; reference symbols: shouldPoll,
certificateIssued, useFetchApi, ReverseProxy, serviceId, POLL_INTERVAL_MS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ebbb7752-b36e-4192-8944-c36f3ec17a71

📥 Commits

Reviewing files that changed from the base of the PR and between 9420214 and 7a27bb6.

📒 Files selected for processing (1)
  • src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx

Comment thread src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx`:
- Around line 26-34: The readiness checks use mixed snapshots (meta and
dataRef.current?.meta) which can combine to a false-positive ready state; fix by
selecting one coherent metadata object (e.g., const currentMeta = meta ??
dataRef.current?.meta) and then compute isActive and certificateIssued from that
single currentMeta (use ReverseProxyStatus.ACTIVE for isActive and check
certificate_issued_at for certificateIssued), and update shouldPoll accordingly;
apply the same change to the analogous check around the other occurrence
referenced (the second computation at line ~46).
- Line 44: The code unconditionally assigns dataRef.current = data which can
overwrite the last-known status with undefined when fetching is disabled; change
the update to only overwrite the ref when a real value is present (e.g., check
data !== undefined/null) so dataRef.current retains the previous cached status
when data is undefined; update the assignment used in ReverseProxyStatusCell
(the dataRef and data variables in that component) to guard the write
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 292774ae-d6de-4a2c-8556-3c674ab714d6

📥 Commits

Reviewing files that changed from the base of the PR and between 7a27bb6 and 3f85bce.

📒 Files selected for processing (1)
  • src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx

Comment on lines +26 to +34
const isActive =
meta?.status === ReverseProxyStatus.ACTIVE ||
dataRef.current?.meta?.status === ReverseProxyStatus.ACTIVE;

const certificateIssued =
!!meta?.certificate_issued_at ||
!!dataRef.current?.meta?.certificate_issued_at;

const shouldPoll = !!enabled && !(isActive && certificateIssued);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use one coherent metadata source for readiness checks

isActive and certificateIssued are currently computed with separate ORs across meta and dataRef.current. That can produce a synthetic (ACTIVE && issued) state from different snapshots, which may stop polling and hide the cell too early.

🔧 Proposed fix
-  const isActive =
-    meta?.status === ReverseProxyStatus.ACTIVE ||
-    dataRef.current?.meta?.status === ReverseProxyStatus.ACTIVE;
-
-  const certificateIssued =
-    !!meta?.certificate_issued_at ||
-    !!dataRef.current?.meta?.certificate_issued_at;
+  const effectiveMeta = dataRef.current?.meta ?? meta;
+  const isActive = effectiveMeta?.status === ReverseProxyStatus.ACTIVE;
+  const certificateIssued = !!effectiveMeta?.certificate_issued_at;

Also applies to: 46-46

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx` around lines 26 -
34, The readiness checks use mixed snapshots (meta and dataRef.current?.meta)
which can combine to a false-positive ready state; fix by selecting one coherent
metadata object (e.g., const currentMeta = meta ?? dataRef.current?.meta) and
then compute isActive and certificateIssued from that single currentMeta (use
ReverseProxyStatus.ACTIVE for isActive and check certificate_issued_at for
certificateIssued), and update shouldPoll accordingly; apply the same change to
the analogous check around the other occurrence referenced (the second
computation at line ~46).

if (data && data?.meta) return !!data?.meta?.certificate_issued_at;
return certificateIssued;
}, [data]);
dataRef.current = data;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve last known data instead of overwriting ref with undefined

Unconditionally assigning dataRef.current = data can clear cached status when fetching is disabled, which can reintroduce stale UI state on later renders.

🔧 Proposed fix
-  dataRef.current = data;
+  if (data !== undefined) {
+    dataRef.current = data;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dataRef.current = data;
if (data !== undefined) {
dataRef.current = data;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/reverse-proxy/table/ReverseProxyStatusCell.tsx` at line 44, The
code unconditionally assigns dataRef.current = data which can overwrite the
last-known status with undefined when fetching is disabled; change the update to
only overwrite the ref when a real value is present (e.g., check data !==
undefined/null) so dataRef.current retains the previous cached status when data
is undefined; update the assignment used in ReverseProxyStatusCell (the dataRef
and data variables in that component) to guard the write accordingly.

@heisbrot heisbrot merged commit 10a8e7b into main Mar 9, 2026
4 checks passed
@heisbrot heisbrot deleted the fix/stale-certificate-issued branch March 9, 2026 09:08
@coderabbitai coderabbitai Bot mentioned this pull request Apr 8, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants