"Cannot call method 'is_node_ready' on a null value.

I’m having an error where it says "Cannot call method ‘is_node_ready’ on a null value.
line 5:
func enter() → empty:
→ if not card_ui.is_node_ready():
→ -> await card_ui.ready():

Your variable card_ui is null instead of referring to a valid node. You probably forgot to assign or initialize your card_ui variable. It’s not possible to say more than that based on what you posted. Can you share more of your code?

1 - card_base_state

extends CardState

func enter() → void:
if not card_ui.is_node_ready():
await card_ui.ready

card_ui.reparent_requested.emit(card_ui)
card_ui.color.color = Color.WEB_GREEN
card_ui.state.text = "BASE"
card_ui.pivot_offset = Vector2.ZERO

func on_gui_input(event: InputEvent) → void:
if event.is_action_pressed(“left_mouse”):
card_ui.pivot_offset = card_ui.get_global_mouse_position() - card_ui.global_position
transition_requested.emit(self, CardState.State.CLICKED)

2 - card_state_machine.gd

class_name CardStateMachine
extends Node

@export var initial_state: CardState

var current_state: CardState
var states := {}

func init(card: CardUI) → void:
for child in get_children():
if child is CardState:
states[child.state] = child
child.transition_requested.connect(_on_transition_requested)
child.card_ui = card

if initial_state:
	initial_state.enter()
	current_state = initial_state

func on_input(event: InputEvent) → void:
if current_state:
current_state.on_gui_input(event)

func on_gui_input(event: InputEvent) → void:
if current_state:
current_state.on_gui_input(event)

func on_mouse_entered() → void:
if current_state:
current_state.on_mouse_entered()

func on_mouse_exited() → void:
if current_state:
current_state.on_mouse_exited()

func _on_transition_requested(from: CardState, to: CardState.State) → void:
if from != current_state:
return

var new_state: CardState = states[to]
if not new_state:
	return

if current_state:
	current_state.exit()

new_state.enter()
current_state = new_state

3 - card_ui.gd

class_name CardUI
extends Control

signal reparent_requested(which_card_ui: CardUI)

@onready var color: ColorRect = $Color
@onready var state: Label = $State
@onready var card_state_machine: CardStateMachine = $CardStateMachine as CardStateMachine

func _ready() → void:
card_state_machine.init(self)

func _input(event: InputEvent) → void:
card_state_machine.on_input(event)

func _on_gui_input(event: InputEvent) → void:
card_state_machine.on_gui_input(event)

func _on_mouse_entered() → void:
card_state_machine.on_mouse_entered()

func _on_mouse_exited() → void:
card_state_machine.on_mouse_exited()