Cura Start GCode retracts instead of extruding

What is the problem?

My pre-print GCode is retracting instead of extruding before each print. I have Octoprint run a short homing script before Cura takes over, heating the hotend/bed and then purging the extruder. I'm not great with GCode (so I think I've just made a beginner's error), but I've tried reversing some of the extrusion values just as a test, but it doesn't seem to make a difference.

Octoprint pre-print script

M117 Homing axes
G28 ; Home x, y, and z
G0 X0.0 Y0.0 F10000 ; jack up the speed
G0 Z-0.17 F1000; Set Z offset
G92 Z0  ; Save Z offset
G0 Z2.0 F1000; Move up a bit

Cura pre-print script

; Ender 3 Custom Start G-code
M117 Heating
M140 S{material_bed_temperature_layer_0} ; start preheating the bed
M104 S{material_print_temperature_layer_0} T0 ; start preheating hotend
G0 X0.1 Y20 Z4.0 F5000.0; Move to start position
M190 S{material_bed_temperature_layer_0} ; heat to Cura Bed setting 
M109 S{material_print_temperature_layer_0} T0 ; heat to Cura Hotend

M117 Purging extruder
G1 X0.1 Y200.0 Z0.3 F1500.0 E30 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
M117 Printing

What did you already try to solve it?

I've tried reversing the E values on the Cura purging script, but I think something is being wonky with how Cura is exporting (this might be a question for a different forum).

Complete Logs

This is the Octoprint terminal output for the section in question
I don't really understand the N9 M104 S{material_print_temperature_layer_0} ?T0100* line, but I assume Cura should have exported the raw value there, as I don't think OctoPi can interpret it?

Send: N7 M117 Heating*91
Recv: ok
Send: N8 M140 S{material_bed_temperature_layer_0}*12
Recv: ok
Send: N9 M104 S{material_print_temperature_layer_0} ?T0*100
Recv: ok
Send: N10 M190 S{material_bed_temperature_layer_0}*56
Recv: ok
Send: N11 M109 S{material_print_temperature_layer_0} ?T0*80
Recv: ok
Send: N12 M117 Preparing extruder*78
Recv: ok
Send: N13 G1 Z2.0 F3000*41
Recv: ok
Send: N14 G1 X0.1 Y20 Z0.3 F5000.0*27
Recv: ok
Send: N15 G1 X0.1 Y200.0 Z0.3 F1500.0 E30*83
Recv: echo: cold extrusion prevented
Recv: echo: cold extrusion prevented
Recv: ok
Send: N16 G1 X0.4 Y200.0 Z0.3 F5000.0*50
Recv: ok
Send: N17 G1 X0.4 Y20 Z0.3 F1500.0 E30*122
Recv: ok
Send: N18 M117 Printing*12

Additional information about your setup

Running Octoprint 1.4.0 on an Ender 3 Pro with a BLTouch and the latest firmware provided by Creality. I realize I should probably upgrade the firmware by myself, but until tonight it was working fine.

Hello @brooon!

Actually Cura should fill in the placeholder ( material_bed_temperature_layer_0) with real values.
So is the Cura pre-print script in Cura or in OctoPrint?

Filament retracting when you think it should be extruding is a classic sign of a relative / absolute extruder setting (M83 / M82) mismatch.

Same thing can happen with absolute / relative (G90, G91) positioning.

When you write scripts, you need to know the absolute / relative state of both extrusion and position. Unfortunately, there's not a "save current state" command so you have to know how the slicer is configured.

Placeholders are a different issue and again, you have to know what your slicer supports and when scripts are interpreted, who is doing the interpreting (slicer or OctoPrint).