Skip to content

feat(add): add support for naming pinned CIDs #10877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KapilSareen
Copy link

This PR adds support for assigning a human-readable name to a pinned CID. Named pins enhance usability by allowing users to refer to content symbolically instead of using raw multihashes.

Changes

  • Introduces the --pin-name flag to ipfs add

Example Usage

$ ipfs add test.go --pin --pin-name testname
added QmdZwVeTRV1m4YKNXUEd2tBjxkag7JY4Lwf2zmcVJbXKfi test.go

$ ipfs pin ls --names
QmesP6bmy8z4fMn2UzuaXpxur8Drm4VcWApqgPeEg47r3g recursive testname

Fixes #10341

@KapilSareen KapilSareen requested a review from a team as a code owner July 17, 2025 22:33
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thank you for submitting this, looks like an useful feature.

Before merging, we need:

  • add short description of the new feature -- ok to reuse example from this PR -- to docs/changelogs/v0.37.md
  • add tests to test/cli that tests ipfs add with --pin-name works as expected
    • confirms --pin-name=foo created pin named foo
    • confirms --pin=false --pin-name=foo produces an error
    • confirms what happens if no value is passed to --pin-name
      • easiest way is to always require name, and don't do any magic
      • if we want to do magic, then it needs to be robus:
        • if in CLI, and not piped, the source filename is used
          • what happens if added file was added from stdin (echo hi | ipfs add --pin-name)? ignore empty name?
        • if in HTTP RPC, we ignore empty name?

@KapilSareen mind adding tests and addressing the behaviors above and making sure the CI is green?

@KapilSareen
Copy link
Author

Done @lidel!

I’ve added tests in test/cli to confirm:

  • --pin-name=foo creates a named pin as expected
  • --pin=false --pin-name=foo returns an error
  • When --pin-name is passed without a value, the filename is used as the pin name

Currently, if the input is from stdin (e.g. echo hi | ipfs add --pin-name), it falls back to an empty string (i.e. no pin name is assigned).

Also added a changelog entry under docs/changelogs/v0.37.md.

Let me know if you'd like the fallback behavior tweaked further or if there's anything else missing!

@lidel lidel mentioned this pull request Jul 22, 2025
42 tasks
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.

ipfs add --name does not exist
2 participants