Handle missing settings.json for Codespaces/Devcontainers#6880
Merged
mitchdenny merged 2 commits intomainfrom Dec 7, 2024
Merged
Handle missing settings.json for Codespaces/Devcontainers#6880mitchdenny merged 2 commits intomainfrom
mitchdenny merged 2 commits intomainfrom
Conversation
… handle missing settings.json file.
Contributor
There was a problem hiding this comment.
Copilot reviewed 4 out of 5 changed files in this pull request and generated no suggestions.
Files not reviewed (1)
- .devcontainer/contributing/devcontainer.json: Language not supported
Comments skipped due to low confidence (2)
src/Aspire.Hosting/Devcontainers/DevcontainerSettingsWriter.cs:86
- [nitpick] The error message 'Codespaces or Devcontainer not detected.' could be more descriptive. Consider changing it to 'Neither Codespaces nor Devcontainer environment detected. Unable to determine the correct settings file path.'
throw new DistributedApplicationException("Codespaces or Devcontainer not detected.");
src/Aspire.Hosting/Devcontainers/DevcontainerSettingsWriter.cs:90
- Ensure that the new behavior introduced by 'EnsureSettingsFileExists' is covered by tests.
async Task EnsureSettingsFileExists(string path, CancellationToken cancellationToken)
6797934 to
a25f33b
Compare
davidfowl
reviewed
Dec 6, 2024
| await writer.WriteAsync("{}".AsMemory(), cancellationToken).ConfigureAwait(false); | ||
| } | ||
| } | ||
| catch (IOException ex) when (ex.Message == $"The file '{path}' already exists.") |
Contributor
There was a problem hiding this comment.
I am gonna assume you tested this 😄
Member
Author
There was a problem hiding this comment.
I did. The race should be pretty rare as well. I was just being cautious.
davidfowl
approved these changes
Dec 7, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… handle missing settings.json file.
Description
This pull request includes several changes to improve handling of what happens when the machine-wide
settings.jsonfile isn't present. The solution is to detect if the file exists and if it isn't - create it. This required a bunch of other collateral changes which are probably good long-term changes towards improving testability (although I still haven't tackled that yet).I've also added Copilot to our contributing devcontainer since we would normally expect this to be present in our local VS installs - it's kinda helpful :)
Fixes #6873
Checklist
<remarks />and<code />elements on your triple slash comments?breaking-changetemplate):doc-ideatemplate):Microsoft Reviewers: Open in CodeFlow