Skip to content

Can't get value by slice path from remove config #2062

@acynothia

Description

@acynothia

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.
  • I am not looking for support or already pursued the available support channels without success.
  • I have checked the troubleshooting guide for my problem, without success.

Viper Version

1.21.0

Go Version

1.24

Config Source

Remove K/V stores

Format

YAML

Repl.it link

No response

Code reproducing the issue

viper/viper.go

Lines 1250 to 1266 in e66ee1a

// Config file next
val = v.searchIndexableWithPathPrefixes(v.config, path)
if val != nil {
return val
}
if nested && v.isPathShadowedInDeepMap(path, v.config) != "" {
return nil
}
// K/V store next
val = v.searchMap(v.kvstore, path)
if val != nil {
return val
}
if nested && v.isPathShadowedInDeepMap(path, v.kvstore) != "" {
return nil
}

Expected Behavior

The same unmarshal key behaviour between local and remote config.

Actual Behavior

unmarshal from remote config (kvstore) using searchMap which can't get value from slice index key path.

Steps To Reproduce

array:
 - a
 - b
viper.Get("array.0") // local config get value 'a'
viper.Get("array.0") // remote config get value nil

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions