Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tomasaschan
Copy link
Contributor

In pflag, we recently made a breaking change in naming to be more inclusive. This change, while doing nothing to address the same uninclusive naming in cobra itself, adjusts to those changes to ensure automatic bumps (if you do them) can continue uninterrupted.

In pflag, we recently made a breaking change in naming to be more inclusive. This change, while doing nothing to address the same uninclusive naming in cobra itself, adjusts to those changes to ensure automatic bumps (if you do them) can continue uninterrupted.
@CLAassistant
Copy link

CLAassistant commented Aug 31, 2025

CLA assistant check
All committers have signed the CLA.

@nadeemc
Copy link

nadeemc commented Aug 31, 2025

Until this is merged, those running into issues can use this go.mod workaround:

// Needed until PR fix is merged:
// https://github.com/spf13/cobra/pull/2303
replace github.com/spf13/cobra => github.com/tomasaschan/cobra v1.9.2-0.20250831200618-527c4d0e1829

@marckhouzam
Copy link
Collaborator

@nadeemc curious why someone would need a workaround since I assume cobra will only break if pointing to the new pflag? Maybe for projects that directly include pflag as well as cobra?

Copy link
Collaborator

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

I like that such names are being updated.
Thanks for being proactive and opening this PR.

Although I would like to make a similar change for cobra, our policy is to be completely backwards compatible, so for the moment at least, I don’t think we should go beyond this current PR

@marckhouzam marckhouzam merged commit 51d6751 into spf13:main Aug 31, 2025
21 checks passed
@marckhouzam marckhouzam added this to the 1.10.0 milestone Aug 31, 2025
@nadeemc
Copy link

nadeemc commented Aug 31, 2025

@nadeemc curious why someone would need a workaround since I assume cobra will only break if pointing to the new pflag? Maybe for projects that directly include pflag as well as cobra?

Hi @marckhouzam!

Thanks for getting this merged!

For me, and others (spf13/pflag#445), running a go mod update and tidy, even though the spf13/cobra version remained at v1.9.1, did break builds because of the pflag bump.

Glad it was a very temporary workaround ;)

@marckhouzam
Copy link
Collaborator

Is this merge good enough or do we need a cobra release for this? I still don’t quite get when things break…

@nadeemc
Copy link

nadeemc commented Aug 31, 2025

@marckhouzam It will need a release to bump spf13/cobra to v1.9.2 or v1.10.0. Otherwise, anyone using go get -u ./... within a directory with go.mod will see something like this:

require (
	github.com/spf13/cobra v1.9.1
)

require (
-	github.com/spf13/pflag v1.0.7 // indirect
+	github.com/spf13/pflag v1.0.8 // indirect
)

Which will break the build without spf13/cobra also having a version bump and being picked up by the go get -u command.

@tomasaschan
Copy link
Contributor Author

Fwiw I tagged v1.0.9 of pflag to avoid breaking users of Cobra until this is in a tagged release, so it is less urgent now than it was.

But we would still like to remove these old names eventually (likely before 2.0), and tagging a Cobra release that includes this patch (and, potentially but not necessarily, further bumps of pflag) will be a prerequisite for us to do that without causing the same kind of breakage across the ecosystem again.

@tomasaschan tomasaschan deleted the bump-pflag branch September 1, 2025 08:44
@jpmcb
Copy link
Collaborator

jpmcb commented Sep 1, 2025

curious why someone would need a workaround since I assume cobra will only break if pointing to the new pflag? Maybe for projects that directly include pflag as well as cobra?

@marckhouzam - yes, this is exactly the scenario that would break downstream consumers of both pflag and cobra: anyone who upgrades to pflag v1.0.8 (via something like go get -u ./...) breaks their cobra builds. This is mostly a design choice by the original Go authors: there's not really the concept of shadow dependencies or multi-versioned dependencies unless you explicitly put them in something like github.com/user/package/v2 where the code path itself is the version.

The blast radius of this was quite large actually: I got pinged by some people that kubernetes/kubernetes builds were failing on their main branch which also ensures that AWS, Google cloud, Nvidia, etc. etc. are not able to build their distros on the tip of their CI/CDs:

https://prow.k8s.io/view/gs/kubernetes-ci-logs/logs/ci-kubernetes-unit-dependencies/1962249657098702848

In the past, cobra has probably been overly cautious about taking any kind of breaking change since there are just so many projects that use it: the APIs are stable and assumed to be non-breaking. Doing anything that breaks that semver contract erodes alot of trust in the library (and us as maintainers).

@tomasaschan
Copy link
Contributor Author

The blast radius of this was quite large actually

As you can probably tell from my original PR message, I had no idea the blast radius of that change in pflag would be this massive. Basically, I (incorrectly) assumed that Cobra users wouldn't notice unless they explicitly tried to upgrade pflag, but of course I realized Cobra itself would need a few small changes to be able to keep rolling forward - hence this PR.

The immediate issues have been resolved now with v1.0.9 which restores the removed names, so anything that got bitten by some autobump thingy should also be fixed by the same autobump thingy without further action required.

That said, it also seems that anything important that broke because of the pflag change used pflag indirectly through Cobra. If you'd like, I'd be happy to include (but not author... PRs welcome!) a set of integration tests on the pflag side to ensure that any change merged there does not have this type of effect downstream.

project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-runner that referenced this pull request Sep 1, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [github.com/spf13/cobra](https://github.com/spf13/cobra) | `v1.9.1` -> `v1.10.1` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fspf13%2fcobra/v1.10.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fspf13%2fcobra/v1.9.1/v1.10.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>spf13/cobra (github.com/spf13/cobra)</summary>

### [`v1.10.1`](https://github.com/spf13/cobra/releases/tag/v1.10.1)

[Compare Source](spf13/cobra@v1.10.0...v1.10.1)

##### πŸ› Fix

- chore: upgrade pflags v1.0.9 by [@&#8203;jpmcb](https://github.com/jpmcb) in [#&#8203;2305](spf13/cobra#2305)

v1.0.9 of pflags brought back `ParseErrorsWhitelist` and marked it as deprecated

**Full Changelog**: <spf13/cobra@v1.10.0...v1.10.1>

### [`v1.10.0`](https://github.com/spf13/cobra/releases/tag/v1.10.0)

[Compare Source](spf13/cobra@v1.9.1...v1.10.0)

#### What's Changed

##### 🚨 Attention!

- Bump pflag to 1.0.8 by [@&#8203;tomasaschan](https://github.com/tomasaschan) in [#&#8203;2303](spf13/cobra#2303)

This version of `pflag` carried a breaking change: it renamed `ParseErrorsWhitelist` to `ParseErrorsAllowlist` which can break builds if both `pflag` and `cobra` are dependencies in your project.

- If you use both `pflag and `cobra`, upgrade `pflag`to 1.0.8 and`cobra`to`1.10.0\`
- ***or*** use the newer, fixed version of `pflag` v1.0.9 which keeps the deprecated `ParseErrorsWhitelist`

More details can be found here: [#&#8203;2303 (comment)](spf13/cobra#2303 (comment))

##### ✨ Features

- Flow context to command in SetHelpFunc by [@&#8203;Frassle](https://github.com/Frassle) in [#&#8203;2241](spf13/cobra#2241)
- The default ShellCompDirective can be customized for a command and its subcommands by [@&#8203;albers](https://github.com/albers) in [#&#8203;2238](spf13/cobra#2238)

##### πŸ› Fix

- Upgrade golangci-lint to v2, address findings by [@&#8203;scop](https://github.com/scop) in [#&#8203;2279](spf13/cobra#2279)

##### πŸͺ  Testing

- Test with Go 1.24 by [@&#8203;harryzcy](https://github.com/harryzcy) in [#&#8203;2236](spf13/cobra#2236)
- chore: Rm GitHub Action PR size labeler by [@&#8203;jpmcb](https://github.com/jpmcb) in [#&#8203;2256](spf13/cobra#2256)

##### πŸ“ Docs

- Remove traling curlybrace by [@&#8203;yedayak](https://github.com/yedayak) in [#&#8203;2237](spf13/cobra#2237)
- Update command.go by [@&#8203;styee](https://github.com/styee) in [#&#8203;2248](spf13/cobra#2248)
- feat: Add security policy by [@&#8203;jpmcb](https://github.com/jpmcb) in [#&#8203;2253](spf13/cobra#2253)
- Update Readme (Warp) by [@&#8203;ericdachen](https://github.com/ericdachen) in [#&#8203;2267](spf13/cobra#2267)
- Add Periscope to the list of projects using Cobra by [@&#8203;anishathalye](https://github.com/anishathalye) in [#&#8203;2299](spf13/cobra#2299)

#### New Contributors

- [@&#8203;harryzcy](https://github.com/harryzcy) made their first contribution in [#&#8203;2236](spf13/cobra#2236)
- [@&#8203;yedayak](https://github.com/yedayak) made their first contribution in [#&#8203;2237](spf13/cobra#2237)
- [@&#8203;Frassle](https://github.com/Frassle) made their first contribution in [#&#8203;2241](spf13/cobra#2241)
- [@&#8203;styee](https://github.com/styee) made their first contribution in [#&#8203;2248](spf13/cobra#2248)
- [@&#8203;ericdachen](https://github.com/ericdachen) made their first contribution in [#&#8203;2267](spf13/cobra#2267)
- [@&#8203;albers](https://github.com/albers) made their first contribution in [#&#8203;2238](spf13/cobra#2238)
- [@&#8203;anishathalye](https://github.com/anishathalye) made their first contribution in [#&#8203;2299](spf13/cobra#2299)
- [@&#8203;tomasaschan](https://github.com/tomasaschan) made their first contribution in [#&#8203;2303](spf13/cobra#2303)

**Full Changelog**: <spf13/cobra@v1.9.1...v1.9.2>

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45MS4yIiwidXBkYXRlZEluVmVyIjoiNDEuOTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9DaG9yZSIsInJ1bi1lbmQtdG8tZW5kLXRlc3RzIl19-->

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/930): <!--number 930 --><!--line 0 --><!--description VXBkYXRlIG1vZHVsZSBnaXRodWIuY29tL3NwZjEzL2NvYnJhIHRvIHYxLjEwLjE=-->Update module github.com/spf13/cobra to v1.10.1<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/930
Reviewed-by: earl-warren <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

5 participants