Skip to content
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

ini: fix IniParser.write() for zero values #332

Merged
merged 1 commit into from
Mar 21, 2021

Conversation

sean-
Copy link
Contributor

@sean- sean- commented Feb 25, 2020

Fixes two different panics when using IniParser.Write():

[Application Options]
panic: reflect: call of reflect.Value.IsZero on zero Value

goroutine 1 [running]:
reflect.Value.IsZero(0x0, 0x0, 0x0, 0xc0005071f0)
	/usr/local/Cellar/go/1.13.7/libexec/src/reflect/value.go:1121 +0x638
github.com/jessevdk/go-flags.convertMarshal(0x0, 0x0, 0x0, 0x4030751, 0x4ce1e40, 0xc000507258, 0xc000507248, 0x40cb502)
	third_party/go/src/github.com/jessevdk/go-flags/convert.go:56 +0x43
github.com/jessevdk/go-flags.convertToString(0x0, 0x0, 0x0, 0x4b87dd2, 0x8c, 0xc0001e4d80, 0x0, 0x0, 0x559b6e0, 0xc000530100)
	third_party/go/src/github.com/jessevdk/go-flags/convert.go:67 +0x5a
github.com/jessevdk/go-flags.convertToString(0x4aa5b40, 0xc000226a50, 0x196, 0x4b87dd2, 0x8c, 0xc0001e4d80, 0x1, 0x16, 0x0, 0x0)
	third_party/go/src/github.com/jessevdk/go-flags/convert.go:153 +0xbe5
github.com/jessevdk/go-flags.writeGroupIni(0xc00036c280, 0xc00025bc20, 0x0, 0x0, 0x4ee9f20, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:284 +0x5b0
github.com/jessevdk/go-flags.writeCommandIni.func1(0xc00025bc20)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:323 +0x72
github.com/jessevdk/go-flags.(*Group).eachGroup(0xc00025bc20, 0xc0005077c8)
	third_party/go/src/github.com/jessevdk/go-flags/group.go:184 +0x30
github.com/jessevdk/go-flags.(*Group).eachGroup(0xc00025bb80, 0xc0005077c8)
	third_party/go/src/github.com/jessevdk/go-flags/group.go:187 +0x67
github.com/jessevdk/go-flags.writeCommandIni(0xc00036c280, 0x0, 0x0, 0x4ee9f20, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:321 +0xcc
github.com/jessevdk/go-flags.writeIni(...)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:345
github.com/jessevdk/go-flags.(*IniParser).Write(0xc00019c690, 0x4ee9f20, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:157 +0x59

and

[Application Options]
panic: reflect: call of reflect.Value.Type on zero Value

goroutine 1 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0x4030700, 0x0)
	/usr/local/Cellar/go/1.13.7/libexec/src/reflect/value.go:1877 +0x166
github.com/jessevdk/go-flags.convertToString(0x0, 0x0, 0x0, 0x4b87db2, 0x8c, 0xc000318d80, 0x0, 0x0, 0x559b6e0, 0xc00050c080)
	third_party/go/src/github.com/jessevdk/go-flags/convert.go:71 +0xa4
github.com/jessevdk/go-flags.convertToString(0x4aa5b20, 0xc000226a50, 0x196, 0x4b87db2, 0x8c, 0xc000318d80, 0x1, 0x16, 0x0, 0x0)
	third_party/go/src/github.com/jessevdk/go-flags/convert.go:153 +0xbe5
github.com/jessevdk/go-flags.writeGroupIni(0xc000338380, 0xc000257d60, 0x0, 0x0, 0x4ee9f00, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:284 +0x5b0
github.com/jessevdk/go-flags.writeCommandIni.func1(0xc000257d60)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:323 +0x72
github.com/jessevdk/go-flags.(*Group).eachGroup(0xc000257d60, 0xc00049f7c8)
	third_party/go/src/github.com/jessevdk/go-flags/group.go:184 +0x30
github.com/jessevdk/go-flags.(*Group).eachGroup(0xc000257cc0, 0xc00049f7c8)
	third_party/go/src/github.com/jessevdk/go-flags/group.go:187 +0x67
github.com/jessevdk/go-flags.writeCommandIni(0xc000338380, 0x0, 0x0, 0x4ee9f00, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:321 +0xcc
github.com/jessevdk/go-flags.writeIni(...)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:345
github.com/jessevdk/go-flags.(*IniParser).Write(0xc00019c980, 0x4ee9f00, 0xc000010018, 0x2)
	third_party/go/src/github.com/jessevdk/go-flags/ini.go:157 +0x59

@@ -68,6 +68,10 @@ func convertToString(val reflect.Value, options multiTag) (string, error) {
return ret, err
}

if !val.IsValid() {
return "", nil
Copy link
Owner

Choose a reason for hiding this comment

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

Should this not produce an error instead?

@jessevdk jessevdk merged commit 0f4c3a3 into jessevdk:master Mar 21, 2021
nabeken added a commit to nabeken/psadm that referenced this pull request Jun 17, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/jessevdk/go-flags](https://github.com/jessevdk/go-flags)
| require | minor | `v1.5.0` -> `v1.6.1` |

---

### Release Notes

<details>
<summary>jessevdk/go-flags (github.com/jessevdk/go-flags)</summary>

###
[`v1.6.1`](https://github.com/jessevdk/go-flags/releases/tag/v1.6.1)

[Compare
Source](https://github.com/jessevdk/go-flags/compare/v1.6.0...v1.6.1)

**Full Changelog**:
jessevdk/go-flags@v1.6.0...v1.6.1

###
[`v1.6.0`](https://github.com/jessevdk/go-flags/releases/tag/v1.6.0)

[Compare
Source](https://github.com/jessevdk/go-flags/compare/v1.5.0...v1.6.0)

#### What's Changed

- ini: fix IniParser.write() for zero values by
[@&#8203;sean-](https://github.com/sean-) in
[jessevdk/go-flags#332
- fix a panic when generating help while the subcommand and all option
groups are hidden by [@&#8203;bboozzoo](https://github.com/bboozzoo)
in
[jessevdk/go-flags#354
- Help for positional args without allcmd.ArgsRequired dependent from
arg.Required by [@&#8203;sv99](https://github.com/sv99) in
[jessevdk/go-flags#342
- Bump golang.org/x/sys from 0.0.0-20210320140829-1e4c9ba3b0c4 to 0.1.0
by [@&#8203;dependabot](https://github.com/dependabot) in
[jessevdk/go-flags#396
- Option to allow passing value to bool flag by
[@&#8203;alexcb](https://github.com/alexcb) in
[jessevdk/go-flags#367
- Add support for SOURCE_DATE_EPOCH for TestMan by
[@&#8203;anthonyfok](https://github.com/anthonyfok) in
[jessevdk/go-flags#376
- Update to run go-flags on AIX by
[@&#8203;llrocha](https://github.com/llrocha) in
[jessevdk/go-flags#390
- Add option for key value delimiter by
[@&#8203;anaprimawaty](https://github.com/anaprimawaty) in
[jessevdk/go-flags#392
- Undersocre support for numbers (set default base for strconv.Parse\*
to 0) by [@&#8203;GRbit](https://github.com/GRbit) in
[jessevdk/go-flags#404
- docs: add ENV variable usage example by
[@&#8203;cemremengu](https://github.com/cemremengu) in
[jessevdk/go-flags#371
- Support per-command PassAfterNonOption by
[@&#8203;woky](https://github.com/woky) in
[jessevdk/go-flags#393
- Upgrade by [@&#8203;jessevdk](https://github.com/jessevdk) in
[jessevdk/go-flags#406

#### New Contributors

- [@&#8203;sean-](https://github.com/sean-) made their first
contribution in
[jessevdk/go-flags#332
- [@&#8203;sv99](https://github.com/sv99) made their first
contribution in
[jessevdk/go-flags#342
- [@&#8203;dependabot](https://github.com/dependabot) made their first
contribution in
[jessevdk/go-flags#396
- [@&#8203;alexcb](https://github.com/alexcb) made their first
contribution in
[jessevdk/go-flags#367
- [@&#8203;anthonyfok](https://github.com/anthonyfok) made their first
contribution in
[jessevdk/go-flags#376
- [@&#8203;llrocha](https://github.com/llrocha) made their first
contribution in
[jessevdk/go-flags#390
- [@&#8203;anaprimawaty](https://github.com/anaprimawaty) made their
first contribution in
[jessevdk/go-flags#392
- [@&#8203;GRbit](https://github.com/GRbit) made their first
contribution in
[jessevdk/go-flags#404
- [@&#8203;cemremengu](https://github.com/cemremengu) made their first
contribution in
[jessevdk/go-flags#371
- [@&#8203;woky](https://github.com/woky) made their first
contribution in
[jessevdk/go-flags#393

**Full Changelog**:
jessevdk/go-flags@v1.5.0...v1.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **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:eyJjcmVhdGVkSW5WZXIiOiIzNy40MDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
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.

2 participants