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

fix: only access propertiesSchema.properties once it's confirmed non-undefined #90

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

TWiStErRob
Copy link

@TWiStErRob TWiStErRob commented Nov 29, 2024

Description 📝

image

running with --debug gave

Trace: {
  isWrappedError: true,
  description: 'An unexpected error occurred.',
  notes: [ "Cannot read properties of undefined (reading 'properties')" ],
  error: TypeError: Cannot read properties of undefined (reading 'properties')
      at getPropertiesSchema (rudder-typer/src/generators/ast.js:45:45)
      at rudder-typer/src/generators/android/android.js:75:32
      at Generator.next (<anonymous>)
      at rudder-typer/src/generators/android/android.js:7:71
      at new Promise (<anonymous>)
      at __awaiter (rudder-typer/src/generators/android/android.js:3:12)
      at Object.generateTrackCall (rudder-typer/src/generators/android/android.js:74:77)
      at rudder-typer/src/generators/gen.js:236:37
      at Generator.next (<anonymous>)
      at fulfilled (rudder-typer/src/generators/gen.js:4:58)
}
    at ErrorBoundary.<anonymous> (rudder-typer/src/cli/commands/error.js:51:25)
    at Generator.next (<anonymous>)
    at rudder-typer/src/cli/commands/error.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (rudder-typer/src/cli/commands/error.js:3:12)
    at ErrorBoundary.reportError (rudder-typer/src/cli/commands/error.js:49:40)
    at ErrorBoundary.<anonymous> (rudder-typer/src/cli/commands/error.js:63:24)
    at Generator.next (<anonymous>)
    at rudder-typer/src/cli/commands/error.js:7:71
    at new Promise (<anonymous>)

Modifying the code to debug, it crashed when event was this:

{
	"name": "identify",
	"type": 5,
	"properties": [
		{
			"name": "traits",
			"type": 5,
			"properties": [
				{
					"name": "value",
					"type": 4,
					"description": "...",
					"isRequired": true
				}
			]
		}
	],
	"description": "My custom identify"
}

in the plan.json this was represented by:

{
	"rules": {
		"events": [
			{
				"description": "My custom identify",
				"eventType": "identify",
				"name": "",
				"rules": {
					"$defs": {
					},
					"$schema": "http://json-schema.org/draft-07/schema#",
					"description": "My custom identify",
					"properties": {
						"traits": {
							"additionalProperties": false,
							"properties": {
								"value": {
									"description": "...",
									"type": [
										"number"
									]
								}
							},
							"required": [
								"value"
							],
							"type": "object"
						}
					},
					"type": "object"
				}
			},

Please add tests for this case.

@contributor-support
Copy link

Thank you @TWiStErRob for contributing this PR.
Please sign the Contributor License Agreement (CLA) before merging.

@akashrpo akashrpo changed the title Only access propertiesSchema.properties once it's confirmed non-undefined fix: only access propertiesSchema.properties once it's confirmed non-undefined Dec 12, 2024
@akashrpo akashrpo merged commit 9103ecb into rudderlabs:develop Dec 16, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants