Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Bug: Incorrect Use of Append Function in StoreKeys Method #469

Description

@yuxuan-xie

Hello Team,
During a recent code review, I found a persistent bug in the StoreKeys method of our Store struct.

func (rs *Store) StoreKeys() []types.StoreKey {
	res := make([]types.StoreKey, len(rs.keysByName))
	for _, sk := range rs.keysByName {
		res = append(res, sk)
	}
	return res
}

The code can be found at

res := make([]types.StoreKey, len(rs.keysByName))

This is a common bug with respect to append. The original code piece are actually appending new keys at the end of some zero-values, thus doubling the slice size.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions