Skip to content

--config override: decode errors name the file "." (filepath.Base self-assignment) #9

Description

@fchimpan

Summary

--config <file>.yaml loads the override file but computes the stored file name from the wrong variable, so the name becomes "." and decode errors read decode .: instead of naming the user's file.

Reproduction

printf 'version: v2\nbadkey: {{{' > custom.yaml
buf build --config custom.yaml
# Failure: decode .: invalid character 'v' looking for beginning of value
#          ^^^^^^^^ should be "decode custom.yaml:"

(Verified against a local build — the output above is real.)

Root cause

private/bufpkg/bufconfig/buf_yaml_file.go:191-197 (GetBufYAMLFileForOverride):

var fileName string
...
case ".json", ".yaml", ".yml":
	data, err = os.ReadFile(override)
	...
	fileName = filepath.Base(fileName)   // self-assignment; fileName is still ""

Should be fileName = filepath.Base(override). filepath.Base("") returns ".", which then becomes the ObjectData name used in error messages.


Found via a full mutest (mutation-testing) run over this repo; verified manually.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions