Skip to content

Commit

Permalink
Merge pull request #5041 from TheThingsNetwork/release/v3.16.3-changes
Browse files Browse the repository at this point in the history
Release v3.16.3
  • Loading branch information
adriansmares authored Dec 23, 2021
2 parents ff220a3 + 5a399a4 commit ac27169
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 57 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ For details about compatibility between different releases, see the **Commitment

### Security

## [3.16.3] - 2021-12-23

### Fixed

- CLI panic when getting devices.
- Application uplink processing serialization behavior in the Application Server.

## [3.16.2] - 2021-12-17

### Added
Expand Down Expand Up @@ -1936,7 +1943,8 @@ For details about compatibility between different releases, see the **Commitment
<!--
NOTE: These links should respect backports. See https://github.com/TheThingsNetwork/lorawan-stack/pull/1444/files#r333379706.
-->
[unreleased]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.16.2...v3.16
[unreleased]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.16.3...v3.16
[3.16.2]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.16.2...v3.16.3
[3.16.2]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.16.1...v3.16.2
[3.16.1]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.16.0...v3.16.1
[3.16.0]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.3...v3.16.0
Expand Down
6 changes: 3 additions & 3 deletions cmd/ttn-lw-cli/commands/end_devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ var (
if device.CreatedAt == nil || (res.CreatedAt != nil && ttnpb.StdTime(res.CreatedAt).Before(*ttnpb.StdTime(device.CreatedAt))) {
device.CreatedAt = res.CreatedAt
}
if ttnpb.StdTime(res.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
if res.UpdatedAt != nil && ttnpb.StdTime(res.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
device.UpdatedAt = res.UpdatedAt
}

Expand Down Expand Up @@ -561,7 +561,7 @@ var (
if device.CreatedAt == nil || (res.CreatedAt != nil && ttnpb.StdTime(res.CreatedAt).Before(*ttnpb.StdTime(device.CreatedAt))) {
device.CreatedAt = res.CreatedAt
}
if ttnpb.StdTime(res.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
if res.UpdatedAt != nil && ttnpb.StdTime(res.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
device.UpdatedAt = res.UpdatedAt
}

Expand Down Expand Up @@ -832,7 +832,7 @@ var (
if device.CreatedAt == nil || (nsDevice.CreatedAt != nil && ttnpb.StdTime(nsDevice.CreatedAt).Before(*ttnpb.StdTime(device.CreatedAt))) {
device.CreatedAt = nsDevice.CreatedAt
}
if ttnpb.StdTime(nsDevice.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
if nsDevice.UpdatedAt != nil && ttnpb.StdTime(nsDevice.UpdatedAt).After(*ttnpb.StdTime(device.UpdatedAt)) {
device.UpdatedAt = nsDevice.UpdatedAt
}
return io.Write(os.Stdout, config.OutputFormat, device)
Expand Down
6 changes: 3 additions & 3 deletions cmd/ttn-lw-cli/commands/end_devices_split.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func getEndDevice(ids *ttnpb.EndDeviceIdentifiers, nsPaths, asPaths, jsPaths []s
if res.CreatedAt == nil || (jsRes.CreatedAt != nil && ttnpb.StdTime(jsRes.CreatedAt).Before(*ttnpb.StdTime(res.CreatedAt))) {
res.CreatedAt = jsRes.CreatedAt
}
if ttnpb.StdTime(jsRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt)) {
if res.UpdatedAt == nil || (jsRes.UpdatedAt != nil && ttnpb.StdTime(jsRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt))) {
res.UpdatedAt = jsRes.UpdatedAt
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func getEndDevice(ids *ttnpb.EndDeviceIdentifiers, nsPaths, asPaths, jsPaths []s
if res.CreatedAt == nil || (asRes.CreatedAt != nil && ttnpb.StdTime(asRes.CreatedAt).Before(*ttnpb.StdTime(res.CreatedAt))) {
res.CreatedAt = asRes.CreatedAt
}
if ttnpb.StdTime(asRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt)) {
if res.UpdatedAt == nil || (asRes.UpdatedAt != nil && ttnpb.StdTime(asRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt))) {
res.UpdatedAt = asRes.UpdatedAt
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func getEndDevice(ids *ttnpb.EndDeviceIdentifiers, nsPaths, asPaths, jsPaths []s
if res.CreatedAt == nil || (nsRes.CreatedAt != nil && ttnpb.StdTime(nsRes.CreatedAt).Before(*ttnpb.StdTime(res.CreatedAt))) {
res.CreatedAt = nsRes.CreatedAt
}
if ttnpb.StdTime(nsRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt)) {
if res.UpdatedAt == nil || (nsRes.UpdatedAt != nil && ttnpb.StdTime(nsRes.UpdatedAt).After(*ttnpb.StdTime(res.UpdatedAt))) {
res.UpdatedAt = nsRes.UpdatedAt
}
}
Expand Down
1 change: 1 addition & 0 deletions cmd/ttn-lw-cli/commands/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func processDownlink(dev *ttnpb.EndDevice, lastUpMsg *ttnpb.Message, downMsg *tt
}

dev.DevAddr, dev.Session.DevAddr = &joinAcceptPayload.DevAddr, joinAcceptPayload.DevAddr
dev.Session.Keys = &ttnpb.SessionKeys{}

if dev.LorawanVersion.Compare(ttnpb.MAC_V1_1) >= 0 && joinAcceptPayload.DlSettings.OptNeg {
appSKey := crypto.DeriveAppSKey(*dev.GetRootKeys().GetAppKey().Key, joinAcceptPayload.JoinNonce, joinEUI, devNonce)
Expand Down
2 changes: 1 addition & 1 deletion data/lorawan-devices
2 changes: 1 addition & 1 deletion data/lorawan-webhook-templates
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttn-stack",
"version": "3.16.2",
"version": "3.16.3",
"description": "The Things Stack",
"main": "index.js",
"repository": "https://github.com/TheThingsNetwork/lorawan-stack.git",
Expand Down
102 changes: 62 additions & 40 deletions pkg/applicationserver/io/packages/redis/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,17 @@ func (r ApplicationPackagesRegistry) ListAssociations(ctx context.Context, ids *
devUID := unique.ID(ctx, ids)
uidKey := r.uidKey(devUID)

lockerID, err := ttnredis.GenerateLockerID()
if err != nil {
return nil, err
opts := []ttnredis.FindProtosOption{}
limit, offset := ttnredis.PaginationLimitAndOffsetFromContext(ctx)
if limit != 0 {
opts = append(opts,
ttnredis.FindProtosSorted(false),
ttnredis.FindProtosWithOffsetAndCount(offset, limit),
)
}

defer trace.StartRegion(ctx, "list application package associations by device id").End()

err = ttnredis.LockedWatch(ctx, r.Redis, uidKey, lockerID, r.LockTTL, func(tx *redis.Tx) (err error) {
opts := []ttnredis.FindProtosOption{ttnredis.FindProtosSorted(false)}

limit, offset := ttnredis.PaginationLimitAndOffsetFromContext(ctx)
if limit != 0 {
total, err := tx.SCard(ctx, uidKey).Result()
if err != nil {
return err
}
ttnredis.SetPaginationTotal(ctx, total)
opts = append(opts, ttnredis.FindProtosWithOffsetAndCount(offset, limit))
}

return ttnredis.FindProtos(ctx, tx, uidKey, r.makeAssociationKeyFunc(devUID), opts...).Range(func() (proto.Message, func() (bool, error)) {
rangeProtos := func(c redis.Cmdable) error {
return ttnredis.FindProtos(ctx, c, uidKey, r.makeAssociationKeyFunc(devUID), opts...).Range(func() (proto.Message, func() (bool, error)) {
pb := &ttnpb.ApplicationPackageAssociation{}
return pb, func() (bool, error) {
pb, err := applyAssociationFieldMask(nil, pb, appendImplicitAssociationGetPaths(paths...)...)
Expand All @@ -154,7 +144,28 @@ func (r ApplicationPackagesRegistry) ListAssociations(ctx context.Context, ids *
return true, nil
}
})
})
}

defer trace.StartRegion(ctx, "list application package associations by device id").End()

var err error
if limit != 0 {
var lockerID string
lockerID, err = ttnredis.GenerateLockerID()
if err != nil {
return nil, err
}
err = ttnredis.LockedWatch(ctx, r.Redis, uidKey, lockerID, r.LockTTL, func(tx *redis.Tx) (err error) {
total, err := tx.SCard(ctx, uidKey).Result()
if err != nil {
return err
}
ttnredis.SetPaginationTotal(ctx, total)
return rangeProtos(tx)
})
} else {
err = rangeProtos(r.Redis)
}
if err != nil {
return nil, ttnredis.ConvertError(err)
}
Expand Down Expand Up @@ -318,27 +329,17 @@ func (r ApplicationPackagesRegistry) ListDefaultAssociations(ctx context.Context
appUID := unique.ID(ctx, ids)
uidKey := r.uidKey(appUID)

lockerID, err := ttnredis.GenerateLockerID()
if err != nil {
return nil, err
opts := []ttnredis.FindProtosOption{}
limit, offset := ttnredis.PaginationLimitAndOffsetFromContext(ctx)
if limit != 0 {
opts = append(opts,
ttnredis.FindProtosSorted(false),
ttnredis.FindProtosWithOffsetAndCount(offset, limit),
)
}

defer trace.StartRegion(ctx, "list application package default associations by application id").End()

err = ttnredis.LockedWatch(ctx, r.Redis, uidKey, lockerID, r.LockTTL, func(tx *redis.Tx) (err error) {
opts := []ttnredis.FindProtosOption{ttnredis.FindProtosSorted(false)}

limit, offset := ttnredis.PaginationLimitAndOffsetFromContext(ctx)
if limit != 0 {
total, err := tx.SCard(ctx, uidKey).Result()
if err != nil {
return err
}
ttnredis.SetPaginationTotal(ctx, total)
opts = append(opts, ttnredis.FindProtosWithOffsetAndCount(offset, limit))
}

return ttnredis.FindProtos(ctx, tx, uidKey, r.makeAssociationKeyFunc(appUID), opts...).Range(func() (proto.Message, func() (bool, error)) {
rangeProtos := func(c redis.Cmdable) error {
return ttnredis.FindProtos(ctx, c, uidKey, r.makeAssociationKeyFunc(appUID), opts...).Range(func() (proto.Message, func() (bool, error)) {
pb := &ttnpb.ApplicationPackageDefaultAssociation{}
return pb, func() (bool, error) {
pb, err := applyDefaultAssociationFieldMask(nil, pb, appendImplicitAssociationGetPaths(paths...)...)
Expand All @@ -349,7 +350,28 @@ func (r ApplicationPackagesRegistry) ListDefaultAssociations(ctx context.Context
return true, nil
}
})
})
}

defer trace.StartRegion(ctx, "list application package default associations by application id").End()

var err error
if limit != 0 {
var lockerID string
lockerID, err = ttnredis.GenerateLockerID()
if err != nil {
return nil, err
}
err = ttnredis.LockedWatch(ctx, r.Redis, uidKey, lockerID, r.LockTTL, func(tx *redis.Tx) (err error) {
total, err := tx.SCard(ctx, uidKey).Result()
if err != nil {
return err
}
ttnredis.SetPaginationTotal(ctx, total)
return rangeProtos(tx)
})
} else {
err = rangeProtos(r.Redis)
}
if err != nil {
return nil, ttnredis.ConvertError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/ttn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/webhandlers/error_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/log"
)

// Data contains data to render templates.
Expand Down Expand Up @@ -90,7 +91,6 @@ func (t *ErrorTemplate) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Year: time.Now().Year(),
IsGenericNotFound: isGenericNotFound,
}); err != nil {
Error(w, r, err)
return
log.FromContext(r.Context()).WithError(err).Warn("Failed to execute template")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class WebhookTemplateForm extends Component {

render() {
const { templateId, webhookTemplate } = this.props
const { name, fields } = webhookTemplate
const { name, fields = [] } = webhookTemplate
const { error, displayOverwriteModal, existingId } = this.state
const validationSchema = Yup.object({
...fields.reduce(
Expand Down
4 changes: 2 additions & 2 deletions pkg/webui/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/gorilla/csrf"
"go.thethings.network/lorawan-stack/v3/pkg/experimental"
"go.thethings.network/lorawan-stack/v3/pkg/log"
"go.thethings.network/lorawan-stack/v3/pkg/webhandlers"
)

Expand Down Expand Up @@ -217,7 +218,6 @@ func (t *AppTemplate) ServeHTTP(w http.ResponseWriter, r *http.Request) {
PageData: pageData,
CSPNonce: cspNonce,
}); err != nil {
webhandlers.Error(w, r, err)
return
log.FromContext(ctx).WithError(err).Warn("Failed to execute template")
}
}
2 changes: 1 addition & 1 deletion sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttn-lw",
"version": "3.16.2",
"version": "3.16.3",
"description": "The Things Stack for LoRaWAN JavaScript SDK",
"url": "https://github.com/TheThingsNetwork/lorawan-stack/tree/default/sdk/js",
"main": "dist/index.js",
Expand Down

0 comments on commit ac27169

Please sign in to comment.