fix url logging (#2617)

## Description

The `GetUri()` call contains side-effects which drain the builder of its constructed url data.  As a result, running a backup with CORSO_URL_LOGGING actually forces the bug to manifest unintentionally.

## Does this PR need a docs update or release note?

- [x]  Yes, it's included

## Type of change

- [x] 🐛 Bugfix

## Test Plan

- [x] 💪 Manual
This commit is contained in:
Keepers 2023-02-22 15:29:55 -07:00 committed by GitHub
parent a9f8c33261
commit 129b96714b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 22 deletions

View File

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Errors from duplicate names in Exchange Calendars
- Resolved an issue where progress bar displays could fail to exit, causing unbounded CPU consumption.
- Fix Corso panic within Docker images
- Debugging with the CORSO_URL_LOGGING env variable no longer causes accidental request failures.
### Changed
- When using Restore and Details on Exchange Calendars, the `--event-calendar` flag can now identify calendars by either a Display Name or a Microsoft 365 ID.
@ -28,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Known Issues
- Nested attachments are currently not restored due to an [issue](https://github.com/microsoft/kiota-serialization-json-go/issues/61) discovered in the Graph APIs
- Breaking changes to Exchange Calendar backups.
- The debugging env variable CORSO_URL_LOGGING causes exchange get requests to fail.
## [v0.3.0] (alpha) - 2023-2-07

View File

@ -252,12 +252,9 @@ func (c Contacts) GetAddedAndRemovedItemIDs(
if err != nil {
logger.Ctx(ctx).Errorw("getting builder info", "error", err)
} else {
uri, err := gri.GetUri()
if err != nil {
logger.Ctx(ctx).Errorw("getting builder uri", "error", err)
} else {
logger.Ctx(ctx).Infow("contact builder", "user", user, "directoryID", directoryID, "uri", uri)
}
logger.Ctx(ctx).
With("user", user, "container", directoryID).
Warnw("builder path-parameters", "path_parameters", gri.PathParameters)
}
}

View File

@ -279,12 +279,9 @@ func (c Events) GetAddedAndRemovedItemIDs(
if err != nil {
logger.Ctx(ctx).Errorw("getting builder info", "error", err)
} else {
uri, err := gri.GetUri()
if err != nil {
logger.Ctx(ctx).Errorw("getting builder uri", "error", err)
} else {
logger.Ctx(ctx).Infow("calendar builder", "user", user, "directoryID", calendarID, "uri", uri)
}
logger.Ctx(ctx).
With("user", user, "container", calendarID).
Warnw("builder path-parameters", "path_parameters", gri.PathParameters)
}
}

View File

@ -290,12 +290,9 @@ func (c Mail) GetAddedAndRemovedItemIDs(
if err != nil {
logger.Ctx(ctx).Errorw("getting builder info", "error", err)
} else {
uri, err := gri.GetUri()
if err != nil {
logger.Ctx(ctx).Errorw("getting builder uri", "error", err)
} else {
logger.Ctx(ctx).Infow("mail builder", "user", user, "directoryID", directoryID, "uri", uri)
}
logger.Ctx(ctx).
With("user", user, "container", directoryID).
Warnw("builder path-parameters", "path_parameters", gri.PathParameters)
}
}

View File

@ -264,10 +264,8 @@ func (handler *LoggingMiddleware) Intercept(
resp, err = pipeline.Next(req, middlewareIndex)
)
if len(os.Getenv("CORSO_URL_LOGGING")) > 0 {
if strings.Contains(req.URL.String(), "users//") {
logger.Ctx(ctx).Errorw("malformed request url: missing user", "url", req.URL)
}
if strings.Contains(req.URL.String(), "users//") {
logger.Ctx(ctx).Errorw("malformed request url: missing resource", "url", req.URL)
}
if resp == nil {