Skip to content

Conversation

@linglingye001
Copy link
Member

Contributing to the Azure SDK

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

Copilot AI review requested due to automatic review settings January 23, 2026 08:31
@github-actions github-actions bot added the App Configuration Azure.ApplicationModel.Configuration label Jan 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds snapshot reference support to the Azure App Configuration SDK, introducing a new SnapshotReferenceConfigurationSetting class that enables configuration settings to reference snapshots. This follows the established pattern of the existing SecretReferenceConfigurationSetting class.

Changes:

  • Added SnapshotReferenceConfigurationSetting class for representing configuration settings that reference snapshots
  • Integrated snapshot reference detection into the deserialization logic
  • Added comprehensive unit and integration tests following established patterns

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/SnapshotReferenceConfigurationSetting.cs New class implementing snapshot reference configuration settings with JSON serialization/deserialization
sdk/appconfiguration/Azure.Data.AppConfiguration/tests/SnapshotReferenceConfigurationSettingTests.cs Comprehensive unit tests covering creation, serialization, edge cases, and error scenarios
sdk/appconfiguration/Azure.Data.AppConfiguration/tests/ConfigurationLiveTests.cs Integration tests for adding, retrieving, updating, and filtering snapshot references
sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/ConfigurationServiceSerializer.cs Added snapshot reference detection during deserialization based on content type
sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/ConfigurationModelFactory.cs Added factory method for creating snapshot reference settings for mocking purposes
sdk/appconfiguration/Azure.Data.AppConfiguration/assets.json Updated test asset tag for new test recordings

Comment on lines +102 to +106
if (document.RootElement.TryGetProperty("snapshot_name", out JsonElement snapshotNameElement) &&
snapshotNameElement.ValueKind == JsonValueKind.String)
{
_snapshotName = snapshotNameElement.GetString();
return true;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an inconsistency in null snapshot name handling. The constructor and property setter allow null snapshot names (tests at lines 30-31 and 42-43 verify this). When GetValue() serializes a null snapshot name, it produces {"snapshot_name": null}. However, TryParseValue() rejects this JSON because line 103 checks for ValueKind == String, which excludes Null. This creates a roundtrip failure: construct with null → get Value → set Value back → now invalid. Consider either: (1) handling JsonValueKind.Null in TryParseValue() to accept null values, (2) preventing null in the constructor/setter, or (3) omitting the snapshot_name property from JSON when null (similar to how other optional properties are handled).

Suggested change
if (document.RootElement.TryGetProperty("snapshot_name", out JsonElement snapshotNameElement) &&
snapshotNameElement.ValueKind == JsonValueKind.String)
{
_snapshotName = snapshotNameElement.GetString();
return true;
if (document.RootElement.TryGetProperty("snapshot_name", out JsonElement snapshotNameElement))
{
if (snapshotNameElement.ValueKind == JsonValueKind.String)
{
_snapshotName = snapshotNameElement.GetString();
return true;
}
if (snapshotNameElement.ValueKind == JsonValueKind.Null)
{
_snapshotName = null;
return true;
}
return false;

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +94
internal override string GetValue()
{
// If the value wasn't valid, return it verbatim.
if (!_isValidValue)
{
return _originalValue;
}

using var memoryStream = new MemoryStream();
using var writer = new Utf8JsonWriter(memoryStream);

writer.WriteStartObject();
writer.WriteString("snapshot_name", _snapshotName);
writer.WriteEndObject();
writer.Flush();

_originalValue = Encoding.UTF8.GetString(memoryStream.ToArray());
return _originalValue;
}
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike SecretReferenceConfigurationSetting, this implementation does not preserve unknown JSON properties when round-tripping values. SecretReferenceConfigurationSetting stores and re-serializes any additional properties beyond "uri", allowing for forward compatibility with future API changes. If the snapshot reference specification allows for additional properties, consider implementing the same preservation logic for consistency and forward compatibility. If additional properties are explicitly not allowed by the specification, this simplified implementation is correct.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Jan 23, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Azure.Data.AppConfiguration

@linglingye001 linglingye001 force-pushed the linglingye/snapshot-ref branch from bc68615 to 3c678ea Compare January 26, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App Configuration Azure.ApplicationModel.Configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants