Skip to content

fix: make sources-files update sources#69

Merged
reubeno merged 23 commits intomicrosoft:mainfrom
PawelWMS:pawelwi/sources_update
Apr 9, 2026
Merged

fix: make sources-files update sources#69
reubeno merged 23 commits intomicrosoft:mainfrom
PawelWMS:pawelwi/sources_update

Conversation

@PawelWMS
Copy link
Copy Markdown
Contributor

@PawelWMS PawelWMS commented Apr 7, 2026

Adding a modification to how source-files config affects the output sources file:

  • New files will be appended to the sources file.
  • The source-files entries must have their hash and hash type provided unless the user passes the --allow-no-hashes flag, which will then retrieve the sources and calculate the missing hashes.
  • If a file name already exists in the sources file, it's considered an error. The user is told to either remove the original entry through an overlay (I'll add it in a separate PR, if it doesn't exist yet) or to re-name the file from source-files.

I've also added config validation for the source-files section of the TOML and update the code to work only with the hash types defined in the HashType* constants.

Copilot AI review requested due to automatic review settings April 7, 2026 01:24
Copy link
Copy Markdown
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 PR updates source preparation so that a component’s source-files configuration can append new entries into the Fedora/RHEL sources file, requiring both hash and hash-type and erroring on filename conflicts.

Changes:

  • Refactors Fedora sources parsing to expose a reusable ParseSourcesFile and adds a FormatSourcesEntry helper.
  • Extends source preparation to append configured source-files entries into the output sources file (with validation and conflict detection).
  • Updates/adds unit tests for the new formatting and sources-file update behavior.

Reviewed changes

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

File Description
internal/providers/sourceproviders/fedorasource/fedorasource.go Introduces exported parsing/formatting helpers and refactors URL-building to use parsed entries.
internal/providers/sourceproviders/fedorasource/fedorasource_test.go Updates hash type assertions and adds coverage for FormatSourcesEntry.
internal/app/azldev/core/sources/sourceprep.go Adds sources file update step during PrepareSources, parsing existing entries and appending new ones from config.
internal/app/azldev/core/sources/sourceprep_test.go Adds tests verifying sources file creation/appending and validation errors.

Comment thread internal/providers/sourceproviders/fedorasource/fedorasource.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/providers/sourceproviders/fedorasource/fedorasource.go
Copilot AI review requested due to automatic review settings April 7, 2026 18:45
Copy link
Copy Markdown
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

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

Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep_test.go Outdated
Copilot AI review requested due to automatic review settings April 8, 2026 19:05
Copy link
Copy Markdown
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread docs/user/reference/config/components.md Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go
Copilot AI review requested due to automatic review settings April 8, 2026 19:57
Copy link
Copy Markdown
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Comment thread internal/projectconfig/configfile.go
Comment thread internal/projectconfig/configfile.go
Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/providers/sourceproviders/fedorasource/fedorasource.go
Comment thread internal/app/azldev/cmds/component/preparesources.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 20:54
Copy link
Copy Markdown
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread internal/providers/sourceproviders/fedorasource/fedorasource.go
Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
Copilot AI review requested due to automatic review settings April 8, 2026 22:43
@PawelWMS PawelWMS force-pushed the pawelwi/sources_update branch from fa1fd8a to 3d52ce6 Compare April 8, 2026 22:48

// HashTypeSHA256 represents the SHA-256 hash algorithm.
HashTypeSHA256 HashType = "sha256"
HashTypeSHA256 HashType = "SHA256"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: all current TOML configs use the upper case version, so this should not break them.

Copy link
Copy Markdown
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

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Comment thread docs/user/reference/config/components.md Outdated
Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/app/azldev/core/sources/sourceprep_test.go
Copilot AI review requested due to automatic review settings April 8, 2026 23:31
Copy link
Copy Markdown
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

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comment thread internal/projectconfig/configfile.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/providers/sourceproviders/fedorasource/fedorasource.go
Copilot AI review requested due to automatic review settings April 9, 2026 00:07
Copy link
Copy Markdown
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment thread internal/utils/fileutils/hash.go
Comment thread internal/projectconfig/component.go Outdated
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Copilot AI review requested due to automatic review settings April 9, 2026 00:22
Copy link
Copy Markdown
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

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

"invalid 'uri' for source file %#q, component %#q; "+
"URI %#q is missing a scheme (e.g. 'https://')",
filename, componentName, origin.Uri)
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

For 'download' origins, validation currently only checks that the URI has some scheme. Since source downloading uses the HTTP downloader (net/http), non-HTTP schemes (e.g. file://, ftp://) and even malformed HTTP(S) URLs with an empty host (e.g. https:///path) will pass config validation but fail later at runtime. Consider restricting schemes to http/https (and requiring a non-empty host for those schemes) so config errors are caught early with a clear message.

Suggested change
}
}
if parsed.Scheme != "http" && parsed.Scheme != "https" {
return fmt.Errorf(
"invalid 'uri' for source file %#q, component %#q; "+
"URI %#q must use 'http' or 'https'",
filename, componentName, origin.Uri)
}
if parsed.Host == "" {
return fmt.Errorf(
"invalid 'uri' for source file %#q, component %#q; "+
"URI %#q must include a host",
filename, componentName, origin.Uri)
}

Copilot uses AI. Check for mistakes.
Comment on lines +563 to +565
if err := fileutils.ValidateFilename(ref.Filename); err != nil {
return nil, fmt.Errorf("invalid filename %#q in 'source-files' configuration:\n%w", ref.Filename, err)
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

FormatSourcesEntry writes the filename verbatim inside parentheses. Filenames containing a closing parenthesis ) (or newlines) will produce a 'sources' entry that ReadSourcesFileEntries cannot parse (its regex stops at )), and will likely break downstream tooling. Since ValidateFilename doesn’t reject these characters, consider adding an explicit validation in buildSourceEntries (or config validation) to reject filenames that can’t be represented in the modern sources-file format, with a clear error.

Copilot uses AI. Check for mistakes.
@reubeno reubeno merged commit b6a9106 into microsoft:main Apr 9, 2026
15 checks passed
@PawelWMS PawelWMS deleted the pawelwi/sources_update branch April 9, 2026 16:21
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.

4 participants