Git Product home page Git Product logo

Comments (5)

tomlarkworthy avatar tomlarkworthy commented on May 23, 2024

run with blaze -v and see if that helps. Let me know the output

Tom

On Wed, Aug 27, 2014 at 12:39 PM, Henrik Strøm [email protected]
wrote:

Often, an error message doesn't contain a line number or any other clue as
to where to find the error.

Example:

$ blaze rules.yaml
transpiling rules.yaml
loading type any definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/any.yaml
loading type boolean definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/boolean.yaml
loading type number definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/number.yaml
loading type object definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/object.yaml
loading type string definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/string.yaml
compile string
compile string
compile string
compile string
compile object
compile object
compile object
compile object
Cannot call method 'has' of undefined

I would really be nice if the error message always contained a line number.


Reply to this email directly or view it on GitHub
#12.

from blaze_compiler.

tomlarkworthy avatar tomlarkworthy commented on May 23, 2024

Oh and if its not confidential can you send me your rules.yaml as well.
Basically there is line and column number error reporting, but some of the
null pointer errors are not covered so you have hit one and I need to fix
that particular case.

Tom

On Wed, Aug 27, 2014 at 1:01 PM, Tom Larkworthy [email protected] wrote:

run with blaze -v and see if that helps. Let me know the output

Tom

On Wed, Aug 27, 2014 at 12:39 PM, Henrik Strøm [email protected]
wrote:

Often, an error message doesn't contain a line number or any other clue
as to where to find the error.

Example:

$ blaze rules.yaml
transpiling rules.yaml
loading type any definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/any.yaml
loading type boolean definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/boolean.yaml
loading type number definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/number.yaml
loading type object definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/object.yaml
loading type string definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/string.yaml
compile string
compile string
compile string
compile string
compile object
compile object
compile object
compile object
Cannot call method 'has' of undefined

I would really be nice if the error message always contained a line
number.


Reply to this email directly or view it on GitHub
#12.

from blaze_compiler.

henrikstroem avatar henrikstroem commented on May 23, 2024

rules.yam file:

functions:
  - isLoggedIn():      auth.username !== null
  - createOnly():      next.exists() && !prev.exists()
  - deleteOnly():      prev.exists() && !next.exists()
  - createOrDelete():  createOnly() || deleteOnly()
  - userOwner():       $userid === auth.username

schema:
  definitions:

    booking:
      type: object

      properties:
        apikey:
          type: string
        date:
          type: string
        phone:
          type: string
        time:
          type: string
        data:
          type: object

      required: [apikey, phone, date, time, data]
      additionalProperties: false

    user:
      type: object

      properties:
        apikey:
          type: string
        email:
          type: string
        name:
          type: string
        password:
          type: string
        phone:
          type: string
        username:
          type: string

        required: [apikey, email, name, password, phone, username]
        additionalProperties: false

  type: object
  properties:
    queue:
      type: object
      $bookingid:
        type: object
        $booking: {$ref: "#/definitions/booking"}
    users:
      type: object
      $userid:
        type: object
        $user: {$ref: "#definitions/user"}

access:
  # everybody can submit bookings to the queue
  - location: queue
    write: createOnly()
    read: false

  # users can update their own bookings
  - location: users/$userid/bookings
    write: userOwner()
    read: userOwner()

Output:

args { _: [ 'rules.yaml' ],
  v: true,
  java: false,
  '$0': '/usr/local/bin/blaze' }
transpiling rules.yaml
loading type any definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/any.yaml
loading type boolean definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/boolean.yaml
loading type number definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/number.yaml
loading type object definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/object.yaml
loading type string definition from /usr/local/lib/node_modules/blaze_compiler/src/../schema/metaschema/string.yaml
annotate_schema { type: 'object',
  '$bookingid': 
   { type: 'object',
     '$booking': { '$ref': '#/definitions/booking' } } }
annotate_schema { type: 'object',
  '$booking': { '$ref': '#/definitions/booking' } }
fetchRef#/definitions/booking
annotate_schema { type: 'string' }
compile string
addConstraint !next.exists() || next.isString()
getField on enum result: undefined { type: 'string' }
annotate_schema { type: 'string' }
compile string
addConstraint !next.exists() || next.isString()
getField on enum result: undefined { type: 'string' }
annotate_schema { type: 'string' }
compile string
addConstraint !next.exists() || next.isString()
getField on enum result: undefined { type: 'string' }
annotate_schema { type: 'string' }
compile string
addConstraint !next.exists() || next.isString()
getField on enum result: undefined { type: 'string' }
annotate_schema { type: 'object' }
compile object
addConstraint !next.exists() || !(next.isString()||next.isNumber()||next.isBoolean())
getField on required result: undefined { type: 'object' }
addConstraint next == null || (true)
annotate_schema { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
compile object
addConstraint !next.exists() || !(next.isString()||next.isNumber()||next.isBoolean())
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
getField on required result: [ 'apikey', 'phone', 'date', 'time', 'data' ] { type: 'object',
  properties: 
   { apikey: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     date: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     phone: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     time: 
      { type: 'string',
        constraint: '(true) && (!next.exists() || next.isString())' },
     data: 
      { type: 'object',
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } },
  required: [ 'apikey', 'phone', 'date', 'time', 'data' ],
  additionalProperties: false }
addConstraint next == null || (true&&next['apikey'].exists()&&next['phone'].exists()&&next['date'].exists()&&next['time'].exists()&&next['data'].exists())
compile object
addConstraint !next.exists() || !(next.isString()||next.isNumber()||next.isBoolean())
getField on required result: undefined { type: 'object',
  '$booking': { '$ref': '#/definitions/booking' },
  patternProperties: { '.*': { '$ref': '#/definitions/booking' } } }
addConstraint next == null || (true)
compile object
addConstraint !next.exists() || !(next.isString()||next.isNumber()||next.isBoolean())
getField on required result: undefined { type: 'object',
  '$bookingid': 
   { type: 'object',
     '$booking': { '$ref': '#/definitions/booking' },
     patternProperties: { '.*': [Object] },
     constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' },
  patternProperties: 
   { '.*': 
      { type: 'object',
        '$booking': [Object],
        patternProperties: [Object],
        constraint: '((true) && (!next.exists() || !(next.isString()||next.isNumber()||next.isBoolean()))) && (next == null || (true))' } } }
addConstraint next == null || (true)
annotate_schema { type: 'object',
  '$userid': { type: 'object', '$user': { '$ref': '#definitions/user' } } }
annotate_schema { type: 'object', '$user': { '$ref': '#definitions/user' } }
fetchRef#definitions/user

From the verbose output I can see where the problem is, but I can't see from the example how to define multiple models - that seems to be the problem.

from blaze_compiler.

tomlarkworthy avatar tomlarkworthy commented on May 23, 2024

Thanks, I am looking into it now ...

On Thu, Aug 28, 2014 at 6:09 PM, Henrik Strøm [email protected]
wrote:

Reopened #12 #12.


Reply to this email directly or view it on GitHub
#12 (comment).

from blaze_compiler.

tomlarkworthy avatar tomlarkworthy commented on May 23, 2024

Hi Henrik,

you did indeed find a hole in the normal error reporting, thanks for finding it! There was another problem after as well

  1. the $ref URL for user was missing a / after the #, and was a case that avoided the normal error reporting (fixed)
  2. the indentation for "required" in the user definition was 1 level too deep, so required was interpreted as properties schema node, not a keyword of the user.

I also think you probably don't want two levels of wildchilds, you probably just want a single list of users and a single list of bookings so:-

  properties:
    queue:
      type: object
      $bookingid: {$ref: "#/definitions/booking"}
    users:
      type: object
      $userid: {$ref: "#definitions/user"} 

instead of :

  properties:
    queue:
      type: object
      $bookingid:
        type: object
        $booking: {$ref: "#/definitions/booking"}
    users:
      type: object
      $userid:
        type: object
        $user: {$ref: "#definitions/user"}

the latter is creating a list of $users inside a list of $userid

from blaze_compiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.