Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

SyntaxError: "[object Object]" is not valid JSON #33

Description

@tatianacue

Hey I think I've come across an issue. When I try to fetch audits on an auditable model, it seems that if an audit entry's oldValues is null, it's unable to parse and it throws this error:

SyntaxError: "[object Object]" is not valid JSON at JSON.parse (<anonymous>) at Object.consume (file:///node_modules/@stouder-io/adonis-auditing/build/index.js:57:38)

Have I configured something wrong? I have tested this solution and it seems to have fixed it:

   consume: (value) => {
      if (!value) return null;
      if (typeof value === 'object') return value;  
      try {
        return JSON.parse(value); 
      } catch (e) {
        console.error("Failed to parse value:", value, e);
        return null
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions