Skip to content

Conversation

GarrettBeatty
Copy link
Contributor

@GarrettBeatty GarrettBeatty commented Jul 28, 2025

Description

Right now if users configure app config with parameter store as the configuration source behind the scenes it fails because we are checking the content type to be application/json. But in this use case the user may have used free form json in parameter store but the content type is application/octet-stream when being sent back from app config. I dont see any reason why we needed this check and we can simply try to parse as json and it fails then throw error.

Motivation and Context

#117 (reply in thread))

Testing

  1. unit tests
  2. Made a sample app that creates param store config in json format and links it to app config as configuration source and then create a console app that reads it using configBuilder.AddAppConfig https://github.com/aws/aws-dotnet-extensions-configuration/tree/gcbeatty/contentsample/samples/AppConfigParameterStore

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

}

private static IDictionary<string, string> ParseConfig(string contentType, Stream configuration)
public static IDictionary<string, string> ParseConfig(string contentType, Stream configuration)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

made public for easier unit testing

Copy link
Member

Choose a reason for hiding this comment

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

We should avoid making things public just for testing purposes because that adds the method to our public API contract. You can enable the InternalVisibleTo assembly attribute if you want and make the method internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in last revision. i had to also enable signing on the test project and include its public key as reference to the regular project https://stackoverflow.com/questions/30943342/how-to-use-internalsvisibleto-attribute-with-strongly-named-assembly

@GarrettBeatty GarrettBeatty requested review from normj and philasmar July 28, 2025 20:59
@GarrettBeatty GarrettBeatty marked this pull request as ready for review July 28, 2025 20:59
@GarrettBeatty GarrettBeatty requested a review from Copilot July 28, 2025 21:00
Copilot

This comment was marked as outdated.

Copy link
Member

@normj normj left a comment

Choose a reason for hiding this comment

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

I'm okay with the change of attempting to always parse JSON and handle the error if it fails but I don't want to make the method public.

}

private static IDictionary<string, string> ParseConfig(string contentType, Stream configuration)
public static IDictionary<string, string> ParseConfig(string contentType, Stream configuration)
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid making things public just for testing purposes because that adds the method to our public API contract. You can enable the InternalVisibleTo assembly attribute if you want and make the method internal.

@GarrettBeatty GarrettBeatty requested review from normj and Copilot July 30, 2025 00:34
Copy link

@Copilot 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 PR removes the content type validation check for AWS AppConfig, allowing it to parse JSON content regardless of the reported Content-Type header. This fixes an issue where AppConfig backed by Parameter Store returns application/octet-stream instead of application/json, causing the configuration to fail loading.

  • Replaces content type validation with direct JSON parsing attempt
  • Adds comprehensive test coverage for various content types and error scenarios
  • Includes integration test for the specific application/octet-stream use case

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Amazon.Extensions.Configuration.SystemsManager/AppConfig/AppConfigProcessor.cs Removes content type switch statement and always attempts JSON parsing with better error handling
test/Amazon.Extensions.Configuration.SystemsManager.Tests/AppConfigProcessorTests.cs Adds comprehensive unit tests for the new parsing logic across different content types
test/Amazon.Extensions.Configuration.SystemsManager.Integ/AppConfigEndToEndTests.cs Adds integration test for octet-stream content type scenario
src/Amazon.Extensions.Configuration.SystemsManager/Amazon.Extensions.Configuration.SystemsManager.csproj Adds InternalsVisibleTo attribute to allow test access to internal methods
test/Amazon.Extensions.Configuration.SystemsManager.Tests/Amazon.Extensions.Configuration.SystemsManager.Tests.csproj Adds assembly signing configuration
.autover/changes/976aa8d4-d143-4f7b-9bf5-762b166d7fb5.json Documents the change for automatic versioning

using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text.Json;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The System.Text.Json using statement is added but JsonException is the only type being used from this namespace. Consider if this import is necessary or if the existing JsonConfigurationParser.Parse method already handles JSON exceptions appropriately.

Suggested change
using System.Text.Json;

Copilot uses AI. Check for mistakes.

@GarrettBeatty GarrettBeatty merged commit 04b9fe1 into dev Aug 2, 2025
8 checks passed
@GarrettBeatty GarrettBeatty deleted the gcbeatty/content branch August 2, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants