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

Replace mapstructure with fork #5377

Merged
merged 1 commit into from Apr 13, 2022
Merged

Conversation

adriansmares
Copy link
Contributor

Summary

Closes #5343
References mitchellh/mapstructure#278

Changes

  • Replace mapstructure with a patched fork which correctly handles typed nil values

Testing

Unit testing + testing with the following diff:

diff --git a/cmd/ttn-lw-stack/commands/root.go b/cmd/ttn-lw-stack/commands/root.go
index 0064f8e60..901f08660 100644
--- a/cmd/ttn-lw-stack/commands/root.go
+++ b/cmd/ttn-lw-stack/commands/root.go
@@ -17,6 +17,7 @@ package commands
 
 import (
        "context"
+       "fmt"
        "os"
        "time"
 
@@ -70,6 +71,8 @@ var (
                                return err
                        }
 
+                       panic(fmt.Sprintf("%v", config.NS.DefaultMACSettings.DesiredADRAckDelayExponent))
+
                        // enable configured experimental features
                        experimental.EnableFeatures(config.Experimental.Features...)
 

Before this PR the value would be a zero value instead of nil (even though the default is nil):

panic: ADR_ACK_DELAY_1

goroutine 1 [running]:
go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-stack/commands.glob..func16(0x42def20?, {0x26b188a?, 0x1?, 0x1?})
        /home/adriansmares/go/src/go.thethings.network/lorawan-stack/cmd/ttn-lw-stack/commands/root.go:74 +0xe8
github.com/spf13/cobra.(*Command).execute(0x42def20, {0xc000e7e9b0, 0x1, 0x1})
        /home/adriansmares/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:835 +0x58b
github.com/spf13/cobra.(*Command).ExecuteC(0x42deca0)
        /home/adriansmares/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
main.main()
        /home/adriansmares/go/src/go.thethings.network/lorawan-stack/cmd/ttn-lw-stack/main.go:26 +0x25
exit status 2

Post PR:

panic: <nil>

goroutine 1 [running]:
go.thethings.network/lorawan-stack/v3/cmd/ttn-lw-stack/commands.glob..func16(0x42def60?, {0x26b188a?, 0x1?, 0x1?})
        /home/adriansmares/go/src/go.thethings.network/lorawan-stack/cmd/ttn-lw-stack/commands/root.go:74 +0xe8
github.com/spf13/cobra.(*Command).execute(0x42def60, {0xc000561370, 0x1, 0x1})
        /home/adriansmares/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:835 +0x58b
github.com/spf13/cobra.(*Command).ExecuteC(0x42dece0)
        /home/adriansmares/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
main.main()
        /home/adriansmares/go/src/go.thethings.network/lorawan-stack/cmd/ttn-lw-stack/main.go:26 +0x25
exit status 2
Regressions

This was already broken.

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@adriansmares adriansmares added bug Something isn't working c/shared This is shared between components labels Apr 12, 2022
@adriansmares adriansmares added this to the v3.19.0 milestone Apr 12, 2022
@adriansmares adriansmares self-assigned this Apr 12, 2022
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Apr 12, 2022
@adriansmares adriansmares merged commit 03b405b into v3.19 Apr 13, 2022
@adriansmares adriansmares deleted the fix/5343-mapstructure-nil branch April 13, 2022 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c/shared This is shared between components dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No downlinks scheduled in LoRaWAN 1.1
3 participants