Skip to content

Conversation

@onionhammer
Copy link
Contributor

@onionhammer onionhammer commented Jan 27, 2025

TL;DR - There's a bug where HotChocolate cannot parse the pagination cursors it generates if the cursor is ordering on a string, and the string contains a ':' character.

When HotChocolate encodes a cursor with multiple keys, if one of the keys is a string containing a ':', it will attempt to encode the colon with a backslash (\), when HotChocolate decodes the cursor, there is a bug where ':' is the escape character.

This pull request switches the escape character defined in CursorParser to be '' instead of ':'

I have updated some existing tests to cover having a colon embedded in the names being sorted on - these tests fail now without this code change.

The cursor value is not a valid guid
at HotChocolate.Pagination.Serialization.GuidCursorKeySerializer.Parse(ReadOnlySpan1 formattedKey) at HotChocolate.Pagination.Serialization.CursorKeySerializerHelper.Parse(ReadOnlySpan1 formattedKey, ICursorKeySerializer serializer)
at HotChocolate.Pagination.Expressions.CursorKey.Parse(ReadOnlySpan1 cursorValue) at HotChocolate.Pagination.Expressions.CursorParser.Parse(String cursor, ReadOnlySpan1 keys)
at HotChocolate.Data.Pagination.EfQueryableCursorPagingHandler1.SliceAsync(IResolverContext context, IQueryableExecutable1 executable, CursorPagingArguments > arguments)
at HotChocolate.Types.Pagination.CursorPagingHandler.HotChocolate.Types.Pagination.IPagingHandler.SliceAsync(IResolverContext context, Object source)
at HotChocolate.Types.Pagination.PagingMiddleware.InvokeAsync(IMiddlewareContext context)

@michaelstaib michaelstaib merged commit bb560d1 into ChilliCream:main Jan 28, 2025
3 checks passed
@michaelstaib michaelstaib self-assigned this Jan 28, 2025
@michaelstaib michaelstaib added the 🍒 cherry-pick Consider cherry-picking these changes into the previous major version. label Jan 28, 2025
@michaelstaib michaelstaib added this to the HC-14.4.0 milestone Jan 28, 2025
michaelstaib added a commit that referenced this pull request Jan 29, 2025
Co-authored-by: Michael Staib <michael@chillicream.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 cherry-pick Consider cherry-picking these changes into the previous major version. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants