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

Avalara does not gracefully handle misconfiguration errors #3813

Closed
spencern opened this Issue Feb 21, 2018 · 6 comments

Comments

3 participants
@spencern
Copy link
Member

spencern commented Feb 21, 2018

Expected behavior

Avalara should gracefully handle bad credentials.

Actual behavior

An error is thrown and the UI locks up

With APILoginId not configured:
Server error logged:

19:24:19.092Z  WARN Reaction: The Avalara package cannot function unless apiLoginId is configured

image

Exception in delivering result of invoking 'accounts/validateAddress': TypeError: Cannot read property 'validated' of undefined
    at http://localhost:3000/app/app.js?hash=5f81338ecbdeddcb9a19780dd2dc5fca3d8b6cf9:27299:17
    at MethodInvoker._callback (http://localhost:3000/packages/meteor.js?hash=b0f12795c8cc1423b5850502871996903f947ed5:1167:22)
    at MethodInvoker._maybeInvokeCallback (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:209:14)
    at MethodInvoker.receiveResult (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:233:12)
    at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:1975:11)
    at Connection.onMessage (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:2169:14)
    at http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:262:13
    at Array.forEach (<anonymous>)
    at ClientStream.forEachCallback (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:353:33)
    at SockJS.socket.onmessage (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:261:18)

That error spawns from this line if (res.validated)

AutoForm.hooks({
  addressBookAddForm: {
    onSubmit: function (insertDoc) {
      var that = this;
      this.event.preventDefault();
      var addressBook = $(this.template.firstNode).closest(".address-book");
      Meteor.call("accounts/validateAddress", insertDoc, function (err, res) {
        // if the address is validated OR the address has already been through the validation process, pass it on
=====>  if (res.validated) {
          Meteor.call("accounts/addressBookAdd", insertDoc, function (error, result) {
            if (error) {
              Alerts.toast(i18next.t("addressBookAdd.failedToAddAddress", {
                err: error.message
              }), "error");

If the package is not configured correctly, then we see this in the server console

modules.js:67965 Objecterr: {message: "The Avalara package is not configured correctly. Cannot continue [bad-configuration]", name: "Error", stack: "Error: The Avalara package is not configured corre…7063aa833005aff7419b3f8c222e877582f1a3e0:2044:15)", code: undefined, signal: undefined}hostname: "localhost:3000"level: 50msg: "Failed to add to cart."name: "reaction-client"pid: undefinedtime: Wed Feb 21 2018 10:17:21 GMT-0800 (PST) {}v: 0__proto__: Object

Steps to reproduce the behavior

  1. Enable Avalara with either bad or missing credentials
  2. Observe that checkout is blocked

Acceptance Criteria

Use Avalara with:

  • Bad credentials
  • No credentials
  • Good credentials

Versions

Node: 8.9.0
NPM: 5.6.0
Meteor Node: 8.9.4
Meteor NPM: 5.6.0
Reaction CLI: 0.27.0
Reaction: 1.8.0
Reaction branch: release-1.8.0
Docker: 17.12.0-ce

For enhancements or other issues, please describe, in as much detail as
possible, how the app should be changed, and how this would benefit other users and developers.

@spencern spencern added the bug label Feb 21, 2018

@zenweasel zenweasel self-assigned this Feb 21, 2018

@aaronjudd

This comment has been minimized.

Copy link
Contributor

aaronjudd commented Feb 22, 2018

  Error: failed [400] {"error":{"code":"ModelStateInvalid","message":"Field 'code' has an invalid length.","target":"HttpRequest","details":[{"code":"MaxStringLengthError","number":14,"message":"Field 'code' has an invalid length.","description":"Field 'code' must be no more than 50 characters in length.","faultCode":"Client","helpLink":"http://developer.avalara.com/avatax/errors/MaxStringLengthError","severity":"Error"}]}}
      at Object.exports.makeErrorByStatus (packages/http.js:176:10)
      at Request._callback (packages/http.js:140:24)
      at Request.self.callback (/Users/aaronjudd/.meteor/packages/http/.1.4.0.1cljnld.igsf++os+web.browser+web.cordova/npm/node_modules/request/request.js:186:22)
      at emitTwo (events.js:126:13)
      at Request.emit (events.js:214:7)
      at Request.<anonymous> (/Users/aaronjudd/.meteor/packages/http/.1.4.0.1cljnld.igsf++os+web.browser+web.cordova/npm/node_modules/request/request.js:1163:10)
      at emitOne (events.js:116:13)
      at Request.emit (events.js:211:7)
      at IncomingMessage.<anonymous> (/Users/aaronjudd/.meteor/packages/http/.1.4.0.1cljnld.igsf++os+web.browser+web.cordova/npm/node_modules/request/request.js:1085:12)
      at Object.onceWrapper (events.js:313:30)
      at emitNone (events.js:111:20)
      at IncomingMessage.emit (events.js:208:7)
      at endReadableNT (_stream_readable.js:1055:12)
      at _combinedTickCallback (internal/process/next_tick.js:138:11)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)```
@aaronjudd

This comment has been minimized.

Copy link
Contributor

aaronjudd commented Feb 22, 2018

Adding address using an incorrect zip (91364) + Office address (Santa Monica, CA 90405).

Server Console

Exception while invoking method 'accounts/addressBookAdd' TypeError: Cannot read property 'data' of undefined
    at parseError (imports/plugins/included/taxes-avalara/server/methods/taxCalc.js:103:22)
    at avaPost (imports/plugins/included/taxes-avalara/server/methods/taxCalc.js:209:25)
    at Object.taxCalc.estimateCart (imports/plugins/included/taxes-avalara/server/methods/taxCalc.js:473:20)
    at MethodInvocation.MethodHooks.after.options (imports/plugins/included/taxes-avalara/server/hooks/hooks.js:28:13)
    at _each (server/api/method-hooks.js:126:36)
    at arrayEach (/Users/aaronjudd/Projects/reaction/node_modules/lodash/_arrayEach.js:15:9)
    at forEach (/Users/aaronjudd/Projects/reaction/node_modules/lodash/forEach.js:38:10)
    at MethodInvocation.MethodHooks._wrappers.(anonymous function) (server/api/method-hooks.js:125:5)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:107:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:1686:15)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at resolve (packages/ddp-server/livedata_server.js:1684:36)
    at new Promise (<anonymous>)
    at Server.applyAsync (packages/ddp-server/livedata_server.js:1683:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1622:26)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at Object.Cart.after.update (imports/plugins/core/taxes/server/hooks/taxes.js:21:14)
    at packages/matb33_collection-hooks.js:486:20
    at Array.forEach (<anonymous>)
    at Function._.each._.forEach (packages/underscore.js:139:11)
    at packages/matb33_collection-hooks.js:485:11
    at Array.forEach (<anonymous>)
    at Function._.each._.forEach (packages/underscore.js:139:11)
    at after (packages/matb33_collection-hooks.js:484:9)
    at Object.<anonymous> (packages/matb33_collection-hooks.js:505:5)
    at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks.js:146:21)
    at ns.Collection.update (packages/mongo/collection.js:580:31)
    at ns.Collection.Mongo.Collection.(anonymous function) (packages/aldeed_collection2-core.js:232:19)
    at ns.Collection.Mongo.Collection.(anonymous function) [as update] (packages/dispatch_run-as-user.js:325:19)
    at shops.forEach.shopId (server/methods/core/shipping.js:238:12)
    at Array.forEach (<anonymous>)
 => awaited here:
    at Promise.await (/Users/aaronjudd/.meteor/packages/promise/.0.10.2.3l079p.0sgmf++os+web.browser+web.cordova/npm/node_modules/meteor-promise/promise_server.js:60:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1635:14)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at Object.Cart.after.update (imports/plugins/core/taxes/server/hooks/taxes.js:21:14)
    at packages/matb33_collection-hooks.js:486:20
    at Array.forEach (<anonymous>)
    at Function._.each._.forEach (packages/underscore.js:139:11)
    at packages/matb33_collection-hooks.js:485:11
    at Array.forEach (<anonymous>)
    at Function._.each._.forEach (packages/underscore.js:139:11)
    at after (packages/matb33_collection-hooks.js:484:9)
    at Object.<anonymous> (packages/matb33_collection-hooks.js:505:5)
    at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks.js:146:21)
    at ns.Collection.update (packages/mongo/collection.js:580:31)
    at ns.Collection.Mongo.Collection.(anonymous function) (packages/aldeed_collection2-core.js:232:19)
    at ns.Collection.Mongo.Collection.(anonymous function) [as update] (packages/dispatch_run-as-user.js:325:19)
    at shops.forEach.shopId (server/methods/core/shipping.js:238:12)
    at Array.forEach (<anonymous>)
    at updateShippingRecordByShop (server/methods/core/shipping.js:224:9)
    at MethodInvocation.shipping/updateShipmentQuotes (server/methods/core/shipping.js:319:7)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:107:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:1686:15)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at resolve (packages/ddp-server/livedata_server.js:1684:36)
    at new Promise (<anonymous>)
    at Server.applyAsync (packages/ddp-server/livedata_server.js:1683:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1622:26)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at MethodInvocation.cart/setShipmentAddress (server/methods/core/cart.js:904:12)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
 => awaited here:
    at Promise.await (/Users/aaronjudd/.meteor/packages/promise/.0.10.2.3l079p.0sgmf++os+web.browser+web.cordova/npm/node_modules/meteor-promise/promise_server.js:60:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1635:14)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at MethodInvocation.cart/setShipmentAddress (server/methods/core/cart.js:904:12)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:107:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:1686:15)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at resolve (packages/ddp-server/livedata_server.js:1684:36)
    at new Promise (<anonymous>)
    at Server.applyAsync (packages/ddp-server/livedata_server.js:1683:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1622:26)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at MethodInvocation.addressBookAdd (server/methods/accounts/accounts.js:352:16)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:107:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Promise (packages/ddp-server/livedata_server.js:715:46)
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:689:23)
    at packages/ddp-server/livedata_server.js:559:43
 => awaited here:
    at Promise.await (/Users/aaronjudd/.meteor/packages/promise/.0.10.2.3l079p.0sgmf++os+web.browser+web.cordova/npm/node_modules/meteor-promise/promise_server.js:60:12)
    at Server.apply (packages/ddp-server/livedata_server.js:1635:14)
    at Server.call (packages/ddp-server/livedata_server.js:1604:17)
    at MethodInvocation.addressBookAdd (server/methods/accounts/accounts.js:352:16)
    at packages/check/match.js:108:16
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:107:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Promise (packages/ddp-server/livedata_server.js:715:46)
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:689:23)
    at packages/ddp-server/livedata_server.js:559:43```
@zenweasel

This comment has been minimized.

Copy link
Member

zenweasel commented Feb 23, 2018

NIce reproduction steps

@zenweasel

This comment has been minimized.

Copy link
Member

zenweasel commented Feb 23, 2018

This ticket is a duplicate of (or at least mostly overlaps with): #3518

@zenweasel zenweasel changed the title Avalara does not gracefully handle errors Avalara does not gracefully handle misconfiguration errors Feb 23, 2018

@zenweasel

This comment has been minimized.

Copy link
Member

zenweasel commented Feb 23, 2018

Changing this ticket to just focus on handling a misconfigured installation since #3518 talks about handling address validation and they probably have different solutions

@zenweasel

This comment has been minimized.

Copy link
Member

zenweasel commented Mar 8, 2018

Closed via #3827

@zenweasel zenweasel closed this Mar 8, 2018

@spencern spencern referenced this issue Mar 8, 2018

Merged

Release 1.9.0 #3941

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.