MariaDB, Triggers and last_insert_id
I try to insert a record with null sample_id

`sample_id` int unsigned NOT NULL,

The sample_id can't be null.  You will probably find NEW.sample_id = 0 inside the trigger if you don't specify a value on insert, since you have declared the column as NOT NULL... so you need to test for that instead:
IF NEW.sample_id = 0 THEN
...

...or change your table definition to allow null values.

Update (for the benefit of future visitors):
MySQL Bug #6295 (yes, from 9 years ago) is resolved in MySQL 5.7.1 and apparently changes this behavior so that NOT NULL validation is not imposed until after the BEFORE trigger is processed.  This behavior will likely make its way into MariaDB at some point also.  If the original poster of this question is using the = 0 test that currently works, it's possible that this behavior change could cause that logic to fail since the timing (or occurrence, at all) of the coercion to from NULL to 0 might also change.

If a column is declared as NOT NULL, it is not permitted to insert NULL into the column or update it to NULL. However, this constraint was enforced even if there was a BEFORE INSERT (or BEFORE UPDATE trigger) that set the column to a non-NULL value. Now the constraint is checked at the end of the statement, per the SQL standard. (Bug #6295, Bug #11744964)
— http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-1.html

See also: http://dev.mysql.com/worklog/task/?id=6030