Skip to content

Commit

Permalink
Fix small nbf->naf bug in db.CreateOrder
Browse files Browse the repository at this point in the history
- still needs unit test
  • Loading branch information
dopey committed Mar 25, 2021
1 parent a785131 commit fd447c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion acme/db/nosql/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nosql
import (
"context"
"encoding/json"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -91,9 +92,10 @@ func (db *DB) CreateOrder(ctx context.Context, o *acme.Order) error {
ExpiresAt: o.ExpiresAt,
Identifiers: o.Identifiers,
NotBefore: o.NotBefore,
NotAfter: o.NotBefore,
NotAfter: o.NotAfter,
AuthorizationIDs: o.AuthorizationIDs,
}
fmt.Printf("dbo = %+v\n", dbo)
if err := db.save(ctx, o.ID, dbo, nil, "order", orderTable); err != nil {
return err
}
Expand Down
10 changes: 10 additions & 0 deletions acme/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package acme

import (
"encoding/json"
"fmt"

"github.com/pkg/errors"
Expand Down Expand Up @@ -337,3 +338,12 @@ func (e *Error) Cause() error {
}
return e.Err
}

// ToLog implements the EnableLogger interface.
func (e *Error) ToLog() (interface{}, error) {
b, err := json.Marshal(e)
if err != nil {
return nil, WrapErrorISE(err, "error marshaling acme.Error for logging")
}
return string(b), nil
}
8 changes: 6 additions & 2 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ func WriteError(w http.ResponseWriter, err error) {

// Write errors in the response writer
if rl, ok := w.(logging.ResponseLogger); ok {
logErr := err
if u, ok := err.(*acme.Error); ok {
logErr = u.Err
}
rl.WithFields(map[string]interface{}{
"error": err,
"error": logErr,
})
if os.Getenv("STEPDEBUG") == "1" {
if e, ok := err.(errs.StackTracer); ok {
if e, ok := logErr.(errs.StackTracer); ok {
rl.WithFields(map[string]interface{}{
"stack-trace": fmt.Sprintf("%+v", e),
})
Expand Down

0 comments on commit fd447c5

Please sign in to comment.