Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-diversion-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')

steps:
Expand All @@ -37,7 +37,7 @@ jobs:
build:
timeout-minutes: 10
name: build
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-diversion-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')

steps:
Expand All @@ -54,7 +54,7 @@ jobs:
test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/imagekit-diversion-csharp' && 'depot-windows-2022' || 'windows-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-windows-2022' || 'windows-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "6.2.0"
".": "6.3.0"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 6.3.0 (2026-07-24)

Full Changelog: [v6.2.0...v6.3.0](https://github.com/imagekit-developer/imagekit-dotnet/compare/v6.2.0...v6.3.0)

### Features

* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([e827186](https://github.com/imagekit-developer/imagekit-dotnet/commit/e82718678fd3289b5cf213b87434418bbc983195))


### Bug Fixes

* **client:** tolerate JSON null in required untyped fields and prefer more specific union variants ([2bec549](https://github.com/imagekit-developer/imagekit-dotnet/commit/2bec549e4d11458a351838320952b6fd96a2742d))

## 6.2.0 (2026-07-14)

Full Changelog: [v6.1.0...v6.2.0](https://github.com/imagekit-developer/imagekit-dotnet/compare/v6.1.0...v6.2.0)
Expand Down
37 changes: 37 additions & 0 deletions src/Imagekit.Tests/Core/JsonDictionaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,43 @@ public void GetNotNullStruct_ThrowsWhenTypeInvalid()
Assert.Contains("'text' must be of type", exception.Message);
}

[Fact]
public void GetNotAbsentElement_ReturnsValue()
{
var dict = new JsonDictionary();
dict.Set("age", 30);

var age = dict.GetNotAbsentElement("age");

Assert.Equal(30, age.GetInt32());
}

[Fact]
public void GetNotAbsentElement_ThrowsWhenKeyAbsent()
{
var dict = new JsonDictionary();

var exception = Assert.Throws<ImageKitInvalidDataException>(() =>
dict.GetNotAbsentElement("missing")
);
Assert.Contains("'missing' cannot be absent", exception.Message);
}

[Fact]
public void GetNotAbsentElement_ReturnsNullElementWhenValueIsNull()
{
var dict = new JsonDictionary(
new Dictionary<string, JsonElement>
{
["nullable"] = JsonSerializer.SerializeToElement<string?>(null),
}
);

var element = dict.GetNotAbsentElement("nullable");

Assert.Equal(JsonValueKind.Null, element.ValueKind);
}

[Fact]
public void GetNullableClass_ReturnsValueWhenPresent()
{
Expand Down
38 changes: 38 additions & 0 deletions src/Imagekit.Tests/Core/MultipartJsonDictionaryTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Text.Json;
using Imagekit.Core;
using Imagekit.Exceptions;

Expand Down Expand Up @@ -205,6 +206,43 @@ public void GetNotNullStruct_ThrowsWhenTypeInvalid()
Assert.Contains("'text' must be of type", exception.Message);
}

[Fact]
public void GetNotAbsentElement_ReturnsValue()
{
var dict = new MultipartJsonDictionary();
dict.Set("age", 30);

var age = dict.GetNotAbsentElement("age");

Assert.Equal(30, age.GetInt32());
}

[Fact]
public void GetNotAbsentElement_ThrowsWhenKeyAbsent()
{
var dict = new MultipartJsonDictionary();

var exception = Assert.Throws<ImageKitInvalidDataException>(() =>
dict.GetNotAbsentElement("missing")
);
Assert.Contains("'missing' cannot be absent", exception.Message);
}

[Fact]
public void GetNotAbsentElement_ReturnsNullElementWhenValueIsNull()
{
var dict = new MultipartJsonDictionary(
new Dictionary<string, MultipartJsonElement>
{
["nullable"] = MultipartJsonSerializer.SerializeToElement<string?>(null),
}
);

var element = dict.GetNotAbsentElement("nullable");

Assert.Equal(JsonValueKind.Null, element.ValueKind);
}

[Fact]
public void GetNullableClass_ReturnsValueWhenPresent()
{
Expand Down
16 changes: 16 additions & 0 deletions src/Imagekit/Core/JsonDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ public T GetNotNullStruct<T>(string key)
return deserialized;
}

/// <summary>
/// Gets the raw JSON element for a key that must be present, without rejecting JSON null.
///
/// <para>Used for values of unknown type, which can be any JSON value including null. A JSON
/// null is returned as a <see cref="JsonElement"/> whose <c>ValueKind</c> is
/// <c>Null</c>.</para>
/// </summary>
public JsonElement GetNotAbsentElement(string key)
{
if (!_rawData.TryGetValue(key, out JsonElement element))
{
throw new ImageKitInvalidDataException($"'{key}' cannot be absent");
}
return element;
}

public override string ToString() =>
JsonSerializer.Serialize(
FriendlyJsonPrinter.PrintValue(this._rawData),
Expand Down
16 changes: 16 additions & 0 deletions src/Imagekit/Core/MultipartJsonDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ public T GetNotNullStruct<T>(string key)
return deserialized;
}

/// <summary>
/// Gets the raw JSON element for a key that must be present, without rejecting JSON null.
///
/// <para>Used for values of unknown type, which can be any JSON value including null. A JSON
/// null is returned as a <see cref="JsonElement"/> whose <c>ValueKind</c> is
/// <c>Null</c>.</para>
/// </summary>
public JsonElement GetNotAbsentElement(string key)
{
if (!_rawData.TryGetValue(key, out MultipartJsonElement element))
{
throw new ImageKitInvalidDataException($"'{key}' cannot be absent");
}
return element.Json;
}

public override string ToString() =>
JsonSerializer.Serialize(
FriendlyJsonPrinter.PrintValue(this._rawData),
Expand Down
2 changes: 1 addition & 1 deletion src/Imagekit/Imagekit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Metadata -->
<AssemblyTitle>Image Kit C#</AssemblyTitle>
<AssemblyName>Imagekit</AssemblyName>
<VersionPrefix>6.2.0</VersionPrefix>
<VersionPrefix>6.3.0</VersionPrefix>
<Description>The official .NET library for the Image Kit API.</Description>
<OutputType>Library</OutputType>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
22 changes: 11 additions & 11 deletions src/Imagekit/Models/Webhooks/UnsafeUnwrapWebhookEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ JsonSerializerOptions options
{
try
{
var deserialized = JsonSerializer.Deserialize<VideoTransformationAcceptedEvent>(
var deserialized = JsonSerializer.Deserialize<UploadPostTransformErrorEvent>(
element,
options
);
Expand All @@ -760,7 +760,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<VideoTransformationReadyEvent>(
var deserialized = JsonSerializer.Deserialize<UploadPreTransformErrorEvent>(
element,
options
);
Expand All @@ -778,7 +778,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<VideoTransformationErrorEvent>(
var deserialized = JsonSerializer.Deserialize<VideoTransformationAcceptedEvent>(
element,
options
);
Expand All @@ -796,7 +796,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<UploadPreTransformSuccessEvent>(
var deserialized = JsonSerializer.Deserialize<VideoTransformationReadyEvent>(
element,
options
);
Expand All @@ -814,7 +814,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<UploadPreTransformErrorEvent>(
var deserialized = JsonSerializer.Deserialize<VideoTransformationErrorEvent>(
element,
options
);
Expand Down Expand Up @@ -850,7 +850,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<UploadPostTransformErrorEvent>(
var deserialized = JsonSerializer.Deserialize<UploadPreTransformSuccessEvent>(
element,
options
);
Expand All @@ -868,7 +868,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<FileCreateEvent>(
var deserialized = JsonSerializer.Deserialize<FileVersionDeleteEvent>(
element,
options
);
Expand All @@ -886,7 +886,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<FileUpdateEvent>(
var deserialized = JsonSerializer.Deserialize<FileDeleteEvent>(
element,
options
);
Expand All @@ -904,7 +904,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<FileDeleteEvent>(
var deserialized = JsonSerializer.Deserialize<FileCreateEvent>(
element,
options
);
Expand All @@ -922,7 +922,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<FileVersionCreateEvent>(
var deserialized = JsonSerializer.Deserialize<FileUpdateEvent>(
element,
options
);
Expand All @@ -940,7 +940,7 @@ JsonSerializerOptions options

try
{
var deserialized = JsonSerializer.Deserialize<FileVersionDeleteEvent>(
var deserialized = JsonSerializer.Deserialize<FileVersionCreateEvent>(
element,
options
);
Expand Down
Loading
Loading