Skip to content

[Repo Assist] fix: use NotSupportedException in CombinedStream; clarify inner isText#1695

Merged
dsyme merged 2 commits intomainfrom
repo-assist/improve-http-stream-exceptions-20260314-a24c76554c4a3c14
Mar 14, 2026
Merged

[Repo Assist] fix: use NotSupportedException in CombinedStream; clarify inner isText#1695
dsyme merged 2 commits intomainfrom
repo-assist/improve-http-stream-exceptions-20260314-a24c76554c4a3c14

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.

Task 5 — Coding Improvements: Http.fs code quality

Two targeted, low-risk improvements to Http.fs:

1. CombinedStream: failwithNotSupportedException

CombinedStream is a read-only, non-seekable stream wrapper. Its unsupported operations (Write, WriteByte, Seek, SetLength, Position.set) previously threw bare System.Exception via failwith. According to .NET stream guidelines, these operations must throw NotSupportedException.

Why this matters: any .NET code that does try ... with :? NotSupportedException (e.g., Stream.CopyToAsync, BCL helpers, third-party libraries) would not catch these bare exceptions. Returning the correct exception type makes the stream behave as a well-formed .NET stream.

Also fixes a typo in the error message: "cannot be determine""cannot be determined".

2. Inner isText rename → isMimeTypeText

The isText outer function contained an identically-named inner function, creating a confusing shadow. The inner function has been renamed isMimeTypeText to clarify the distinction. An explanatory comment was added to make the semicolon-split purpose explicit.

No behavioural change — the logic is identical.

Changes

  • src/FSharp.Data.Http/Http.fs: CombinedStream raises NotSupportedException; inner isText renamed
  • tests/FSharp.Data.Core.Tests/Http.fs: two tests updated to expect NotSupportedException instead of Exception
  • RELEASE_NOTES.md: version bumped to 8.1.1

Test Status

  • ✅ Build: 0 errors, pre-existing NETSDK1212 warnings only
  • ✅ All 136 Http tests pass (including the 2 updated tests)

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

… for clarity

- CombinedStream.Length, Position.set, Seek, SetLength, Write, WriteByte now raise
  NotSupportedException instead of bare Exception via failwith.
  This is the correct exception type for unsupported stream operations per .NET
  guidelines, and fixes code that catches NotSupportedException not catching these.
- Fix typo in Length error message: 'cannot be determine' → 'cannot be determined'
- Rename shadowed inner isText helper to isMimeTypeText for code clarity;
  add explanatory comment about the semicolon-split logic.
- Update tests to expect NotSupportedException instead of Exception.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 14, 2026 15:14
@dsyme dsyme merged commit 1ee7eaf into main Mar 14, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/improve-http-stream-exceptions-20260314-a24c76554c4a3c14 branch March 14, 2026 15:14
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.

1 participant