Skip to content

config: resolve LoadHTTPConfigFile paths relative to the config file#925

Merged
roidelapluie merged 1 commit into
prometheus:mainfrom
roidelapluie:roidelapluie/fix-loadhttpconfigfile-dir
Jun 17, 2026
Merged

config: resolve LoadHTTPConfigFile paths relative to the config file#925
roidelapluie merged 1 commit into
prometheus:mainfrom
roidelapluie:roidelapluie/fix-loadhttpconfigfile-dir

Conversation

@roidelapluie

Copy link
Copy Markdown
Member

LoadHTTPConfigFile called SetDirectory with filepath.Dir(filepath.Dir(filename)), resolving relative file paths (http_headers files, *_file credentials) against the config file's grandparent directory instead of its own directory. This contradicts the SetDirectory contract and every other config loader.

The behavior was masked by the testdata fixtures, which prefixed file paths with the config file's own directory name (e.g. files: [testdata/headers-file] for a config living in testdata/) to compensate. Drop those redundant prefixes and add a regression test that loads a config from a temp dir and asserts a plain relative path resolves next to the config file.

LoadHTTPConfigFile called SetDirectory with filepath.Dir(filepath.Dir(filename)),
resolving relative file paths (http_headers files, *_file credentials) against the
config file's grandparent directory instead of its own directory. This contradicts
the SetDirectory contract and every other config loader.

The behavior was masked by the testdata fixtures, which prefixed file paths with
the config file's own directory name (e.g. files: [testdata/headers-file] for a
config living in testdata/) to compensate. Drop those redundant prefixes and add a
regression test that loads a config from a temp dir and asserts a plain relative
path resolves next to the config file.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

@krajorama krajorama left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix looks ok, but it should be mentioned in the changelog as it is breaking.

@roidelapluie roidelapluie merged commit e3c14a0 into prometheus:main Jun 17, 2026
8 checks passed
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.

2 participants