Skip to content

Pin the auth mount gate to its behaviour, not one spelling of the guard - #10307

Merged
danielhanchen merged 5 commits into
mainfrom
fix-auth-mount-guard-assertion
Sep 4, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
fix-auth-mount-guard-assertion

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Repo tests (CPU) is red on main at 99a83f6a6 and a2a4143ce, and so on PRs branched from them, on one test out of 15,899:

FAILED tests/studio/test_auth_form_input_count.py::test_auth_flow_routes_do_not_mount_global_settings
  assert 'if (!active || !mounted) return null;' in mount

#10237 is right, and it did not open the auth routes

That PR gave SettingsDialogMount a second surface, so the single lazy-mount flag became two:

-  const [mounted, setMounted] = useState(open || monitorOpen);
-  if (!active || !mounted) return null;
+  if (!active || !(settingsMounted || monitorMounted)) return null;

The auth gate is untouched. !active still short-circuits, so an inactive mount still renders nothing, which is the whole of what this test is named for. What changed is the lazy-mount bookkeeping beside it, and the assertion happened to quote both halves as one string.

The other two assertions in this test still match byte for byte: <SettingsDialogMount active={active && ready} /> and <CredentialBootstrapGate active={!isAuthFlowRoute}>. So the chain the test actually cares about, auth route to active={false} to nothing rendered, is intact at every link.

The change

Assert that SettingsDialogMount returns null whenever it is not active, without naming the rest of the condition.

mount_body = mount[mount.index("export function SettingsDialogMount("):]
assert re.search(r"if \(!active(\)|\s*\|\|[^\n]*\))\s*return null;", mount_body)

Two details are deliberate:

  • Scoped to the SettingsDialogMount body. SettingsDialogLoading above it also carries if (!active) return null;, so an unscoped search would still pass with this guard deleted outright.
  • || ... is accepted after !active and && ... is not. The return has to happen on every inactive render, not just some, and && would let an inactive mount render.

This is the same shape as #10267, #10231, #10289 and #10297: an assertion written as one exact literal over something that was never fixed. This file had already reached that conclusion twice on its own, once as "Lock the count, not the spelling, so a rename does not falsely fail" and once as "Lock the behaviour, not one spelling of it, so either form passes". This assertion is the one that did not get the treatment.

Verified by breaking it

Eight edits to settings-dialog-mount.tsx, each run against the test, next to what a plain re-sync of the literal to today's guard would give:

edit re-synced literal this change
baseline passed passed
both mount flags renamed failed passed
a third surface joins the mount failed passed
the operands reordered failed passed
back to a single flag, as before #10237 failed passed
the !active half dropped failed failed
` becomes&&`, so inactive can still render
the whole guard deleted failed failed
the gate inverted to active failed failed

The first four rows are the point. A re-sync goes red on any of them, none of which touches the auth routes, and the next one is as likely as #10237 was. The last four confirm the test still fails for every way the gate can actually break, including the guard being deleted while the identical line in SettingsDialogLoading stays put.

tests/studio: no other test changes. No source changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T18:38:20.913573Z 288f003 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 288f00339e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +273 to +275
before = body[: match.start()]
if before.count("{") - before.count("}") != 1:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Account for enclosing unbraced control statements

When the candidate guard is nested under an unbraced control statement, such as if (ready) if (!active || !mounted) return null;, the brace count is still one, so this helper accepts it as a component-level guard. If ready is false while active is false, the guard is skipped and the component can render, leaving this auth-route contract green despite the regression; determining scope solely from brace depth does not establish that the guard executes unconditionally.

Useful? React with 👍 / 👎.

Comment on lines +229 to +234
elif source[index] in "\"'`":
quote, stop = source[index], index + 1
while stop < end and source[stop] != quote:
stop += 2 if source[stop] == "\\" else 1
out[index + 1 : stop] = " " * max(0, stop - index - 1)
index = min(stop + 1, end)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Blank regular-expression literals before scanning guards

When the component contains a regex literal such as /if (!active) return null;/ but no executable inactive guard, _blanked leaves that literal untouched and _inactive_returns_null interprets its contents as code. The test therefore passes while an inactive mount renders; regex bodies need to be excluded alongside comments and quoted strings before the textual parser searches for guards.

Useful? React with 👍 / 👎.

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.

1 participant