Skip to content

Commit 1526dbc

Browse files
authored
.Net: Support CollectionExistsAsync with redis alpine (#13244)
### Motivation and Context #12734 Redis alpine produces a different error message for not found indices to redis stack. ### Description - Support CollectionExistsAsync with redis alpine ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 5948dbc commit 1526dbc

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎dotnet/src/VectorData/Redis/RedisHashSetCollection.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public override async Task<bool> CollectionExistsAsync(CancellationToken cancell
128128
await this._database.FT().InfoAsync(this.Name).ConfigureAwait(false);
129129
return true;
130130
}
131-
catch (RedisServerException ex) when (ex.Message.Contains("Unknown index name"))
131+
// "Unknown index name" is returned in Redis Stack
132+
// "no such index" is returned in Redis Alpine
133+
catch (RedisServerException ex) when (ex.Message.Contains("Unknown index name") || ex.Message.Contains("no such index"))
132134
{
133135
return false;
134136
}

‎dotnet/src/VectorData/Redis/RedisJsonCollection.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public override async Task<bool> CollectionExistsAsync(CancellationToken cancell
141141
await this._database.FT().InfoAsync(this.Name).ConfigureAwait(false);
142142
return true;
143143
}
144-
catch (RedisServerException ex) when (ex.Message.Contains("Unknown index name"))
144+
// "Unknown index name" is returned in Redis Stack
145+
// "no such index" is returned in Redis Alpine
146+
catch (RedisServerException ex) when (ex.Message.Contains("Unknown index name") || ex.Message.Contains("no such index"))
145147
{
146148
return false;
147149
}

0 commit comments

Comments
 (0)