Skip to content

[Repo Assist] Fix #1383: Throw NotSupportedException for unrecognized CSS pseudo-classes#1613

Merged
dsyme merged 3 commits intomainfrom
repo-assist/fix-css-pseudo-class-error-1383-0c2f7cb5d8a48819
Feb 22, 2026
Merged

[Repo Assist] Fix #1383: Throw NotSupportedException for unrecognized CSS pseudo-classes#1613
dsyme merged 3 commits intomainfrom
repo-assist/fix-css-pseudo-class-error-1383-0c2f7cb5d8a48819

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist, an AI assistant.

Closes #1383

Root Cause

When HtmlDocument.CssSelect encounters a CSS pseudo-class or pseudo-element that is not implemented (e.g. :nth-child(1), :first-child, :not()), the tokenizer falls through to the generic catch-all case and throws a generic System.Exception with message "Invalid css selector syntax (char ':' at offset 0)". This message is misleading — the syntax is valid CSS, it's just not yet supported by FSharp.Data's CSS selector engine.

Fix

Added a specific case for the : character in the tokenizer (after all the recognised pseudo-class patterns) that reads the pseudo-class name and throws NotSupportedException with a clear, actionable message pointing to the documentation.

Before:

System.Exception: Invalid css selector syntax (char ':' at offset 0)
```

**After:**
```
System.NotSupportedException: CSS pseudo-class or pseudo-element ':nth-child' is not supported.
  See (fsprojects.github.io/redacted) for the list of supported selectors.

Trade-offs

  • NotSupportedException is a more appropriate exception type than Exception for a known limitation.
  • The error message now clearly distinguishes "unsupported but valid CSS" from "invalid CSS syntax".
  • No functional behaviour changes for selectors that are already supported.

Test Status

  • dotnet build succeeded (0 warnings relating to this change, 0 errors)
  • ✅ All 30 existing HtmlCssSelectors tests pass
  • ✅ Fantomas formatting check passed (dotnet fantomas --check)

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@0d6e8cf9db90470cd5477c6a40b350fd9f9e1422. View source at https://github.com/githubnext/agentics/tree/0d6e8cf9db90470cd5477c6a40b350fd9f9e1422/workflows/repo-assist.md.

…asses

Instead of the misleading 'Invalid css selector syntax' error, throw
NotSupportedException with a descriptive message when an unrecognized
CSS pseudo-class or pseudo-element (e.g. :nth-child, :first-child) is
encountered. This makes it clear the syntax is valid CSS but not yet
implemented in FSharp.Data's CSS selector engine.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

✅ Pull request created: #1613

@dsyme dsyme marked this pull request as ready for review February 22, 2026 18:47
@github-actions
Copy link
Contributor Author

🤖 This is an automated comment from Repo Assist.

CI Status Update

Linux ✅ passed — all tests pass on Ubuntu.

Windows ❌ failed — this failure is not caused by the changes in this PR. The failing test is:

XElement.Request includes default User-Agent header

The test is failing because the local ASP.NET Core Kestrel test server can't bind to localhost:49859 due to a Windows socket permission error (Error 10013 — WSAEACCES). This is an intermittent infrastructure issue on the Windows CI runner, unrelated to the CSS pseudo-class fix. The same failure appears on other PRs that also don't touch HTTP/socket code.

The fix in this PR (throwing NotSupportedException for unrecognised CSS pseudo-classes instead of Exception) is correct and the implementation is unaffected by this CI noise. A re-run of CI may produce a green result if the port is available, or a reviewer can approve based on the passing Linux run.

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5. View source at https://github.com/githubnext/agentics/tree/ee50a3b7d1d3eb4a8c409ac9409fd61c9a66b0f5/workflows/repo-assist.md.

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • schemas.microsoft.com
  • tomasp.net

@dsyme dsyme merged commit 0514825 into main Feb 22, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-css-pseudo-class-error-1383-0c2f7cb5d8a48819 branch February 22, 2026 19:31
github-actions bot added a commit that referenced this pull request Feb 23, 2026
Add entries for:
- #1613: CSS pseudo-class NotSupportedException fix (#1383)
- #1617: ConvertDateTimeOffset xs:dateTime fallback fix (#1437)
- #1618: Microsoft.Build security bump
- #1619: XmlProvider EmbeddedResource GetSchema fix (#1310)
- #1621: StrictBooleans parameter for CsvProvider
- #1625: CsvProvider.InferRows multiline quoted field fix (#1439)
- #1626: XSD group reference cycle guard (#1419)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Html Parser: Invalid css selector syntax exception thrown for css pseudo-classes

1 participant