ember-cp-validations icon indicating copy to clipboard operation
ember-cp-validations copied to clipboard

Newest beta (.5) breaks apps with older version of ember-decorators

Open CodingDive opened this issue 6 years ago • 2 comments

Hey, thank you for all the work on this addon.

Environment

  • Ember Version: 3.5.1
  • Ember CLI Version:3.7.1
  • Ember CP Validations Version: 4.0.0-beta.5

I couldn't find an easy way to reproduce this issue but anytime I visit a route that fetches some data, I'm getting following error

EmberError {stack: "Error: Assertion Failed: '{ finisher: [Function:fi…js:235921:40)↵    at Generator.next (<anonymous>)", description: undefined, fileName: undefined, lineNumber: undefined, message: "Assertion Failed: '{ finisher: [Function:finisher] }' does not appear to be an ember-data model", …}

It took me a long time to find the cause of this error since I was specifying the ember-cp-validations version with the caret ^ like ^4.0.0-beta.3. As a result, a few computers that deleted the package-lock.json and ran npm install anew were getting the error while others who were still on the older version were not effected. By now, I have upgraded ember-decorators and it works fine with the newest beta.

Maybe adding ember-decorators as a peer dependency would help others running into the same issue.

Below is my package.json at the time of getting the error. Everything worked fine with 4.0.0-beta.4 installed which probably means it was caused by the changes in https://github.com/offirgolan/ember-cp-validations/pull/619/commits/22d5224b7cdffc6eaa515ffceb9a318f27c85956

package.json
  "@ember-decorators/babel-transforms": "^2.1.1",
  "@ember-intl/cp-validations": "^4.0.1",
  "@ember/jquery": "^0.5.2",
  "@ember/optional-features": "^0.6.3",
  "@types/chai": "^4.1.4",
  "@types/ember-mocha": "^0.14.2",
  "@types/mocha": "^5.2.5",
  "babel-eslint": "^8.2.6",
  "broccoli-asset-rev": "^2.7.0",
  "ember-ajax": "^3.1.0",
  "ember-auto-import": "^1.2.19",
  "ember-cli": "~3.5.1",
  "ember-cli-app-version": "^3.2.0",
  "ember-cli-babel": "^6.16.0",
  "ember-cli-chai": "^0.5.0",
  "ember-cli-dependency-checker": "^3.0.0",
  "ember-cli-eslint": "^4.2.3",
  "ember-cli-htmlbars": "^3.0.0",
  "ember-cli-htmlbars-inline-precompile": "^1.0.3",
  "ember-cli-image-transformer": "^1.4.0",
  "ember-cli-inject-live-reload": "^1.8.2",
  "ember-cli-mirage": "^0.4.9",
  "ember-cli-moment-shim": "^3.7.1",
  "ember-cli-sass": "^8.0.1",
  "ember-cli-shims": "^1.2.0",
  "ember-cli-sri": "^2.1.1",
  "ember-cli-template-lint": "^1.0.0-beta.2",
  "ember-cli-uglify": "^2.1.0",
  "ember-cli-uuid": "^0.6.0",
  "ember-cli-yuidoc": "^0.8.8",
  "ember-concurrency": "^0.8.20",
  "ember-concurrency-decorators": "0.0.4",
  "ember-cp-validations": "4.0.0-beta.5",
  "ember-data": "~3.5.0",
  "ember-decorators": "^2.4.1",
  "ember-engines": "^0.5.23",
  "ember-export-application-global": "^2.0.0",
  "ember-fetch": "^5.1.3",
  "ember-font-awesome": "^4.0.0-rc.4",
  "ember-intl": "^3.2.6",
  "ember-light-table": "^2.0.0-beta.1",
  "ember-load-initializers": "^1.1.0",
  "ember-maybe-import-regenerator": "^0.1.6",
  "ember-mocha": "^0.14.0",
  "ember-moment": "^7.7.0",
  "ember-paper": "^1.0.0-beta.20",
  "ember-power-select": "^2.0.9",
  "ember-power-select-with-create": "^0.6.1",
  "ember-resolver": "^5.0.1",
  "ember-responsive": "^2.0.8",
  "ember-scrollable": "^0.5.0",
  "ember-simple-auth": "^1.7.0",
  "ember-source": "~3.5.1",
  "ember-test-selectors": "^1.0.0",
  "ember-truth-helpers": "^2.1.0",
  "ember-web-app": "^2.3.0",
  "eslint-plugin-ember": "^5.2.0",
  "eslint-plugin-ember-data-sync-relationships": "^1.0.0",
  "husky": "^1.1.3",
  "lint-staged": "^7.2.2",
  "loader.js": "^4.7.0",
  "sass": "^1.14.3"

CodingDive avatar Jan 23 '19 13:01 CodingDive

@ReasonableDeveloper I'm not entirely sure what the issue is that you're facing. In terms of this library, ember-decorators is only specified as a devDependency. Having it as a peerDependency would require the host app to use ember-decorators (or at least warn them of an unmet peer dependency) which I think would be a heavy handed approach considering the decorator usage is optional. That specified commit and the following beta version bump was to migrate to the new Stage 2 implementation of the decorator spec as well unblock anyone that has upgraded to the latest ember-decorators.

From what it looks like, that caret trolled you 😅

offirgolan avatar Jan 31 '19 05:01 offirgolan

Yes, the caret trolled me big time. I learned my lesson and now lock in the version of my dependencies that are still in beta. :grinning: Maybe there is some way to throw a proper error if someone uses ember-decorators by checking if the version they are using is outdated and not compatible with this library. Or are you saying that it shouldn't have caused an error in the first place? I was on version 2.4.1 which means it only supported the stage1 decorator proposal. I think newer versions of ember-decorators are meant to work with both stages but maybe this was causing the issue?

CodingDive avatar Feb 05 '19 12:02 CodingDive

Since this is old and new releases have come out since, I am going to close this issue. If you are still having problems, please open a new issue!

RobbieTheWagner avatar Feb 07 '23 17:02 RobbieTheWagner