dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.17k stars 9.93k forks source link

ArgumentException while OutputCache is cached #55988

Open abratv opened 3 months ago

abratv commented 3 months ago

Is there an existing issue for this?

Describe the bug

Hi,

I got error message in log while i swear my endpoint output is cached Any how I can find what the cause of this exception?

Moved from https://github.com/StackExchange/StackExchange.Redis/issues/2732

Expected Behavior

Steps To Reproduce

Exceptions (if any)

System.ArgumentException: A null value is not valid in this context at StackExchange.Redis.RedisValue.AssertNotNull() in //src/StackExchange.Redis/RedisValue.cs:line 308 at StackExchange.Redis.RedisDatabase.ScriptEvalMessage..ctor(Int32 db, CommandFlags flags, RedisCommand command, String script, Byte[] hexHash, RedisKey[] keys, RedisValue[] values) in //src/StackExchange.Redis/RedisDatabase.cs:line 4814 at StackExchange.Redis.RedisDatabase.ScriptEvalMessage..ctor(Int32 db, CommandFlags flags, RedisCommand command, String script, RedisKey[] keys, RedisValue[] values) in //src/StackExchange.Redis/RedisDatabase.cs:line 4790 at StackExchange.Redis.RedisDatabase.ScriptEvaluateAsync(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) in //src/StackExchange.Redis/RedisDatabase.cs:line 1547 at Microsoft.AspNetCore.OutputCaching.StackExchangeRedis.RedisOutputCacheStore.Microsoft.AspNetCore.OutputCaching.IOutputCacheBufferStore.SetAsync(String key, ReadOnlySequence1 value, ReadOnlyMemory1 tags, TimeSpan validFor, CancellationToken cancellationToken) at Microsoft.AspNetCore.OutputCaching.OutputCacheEntryFormatter.StoreAsync(String key, OutputCacheEntry value, HashSet`1 tags, TimeSpan duration, IOutputCacheStore store, ILogger logger, CancellationToken cancellationToken)

.NET Version

8

Anything else?

No response

abratv commented 3 months ago

Just learned how to debug aspnetcore source code...

The issue caused by null tag (not the value of the cache itself) I have more than one tags, one of it has null value

maybe context.Tags.Add(xxx); //if xxx is null, then throw over here already?

abratv commented 3 months ago

but having exception in policy is not nice just log it with warn? reason is that cache tag may or may not available the endpoint queries might be there or not there

mgravell commented 3 months ago

Propose there are 2 bugs here: