I am trying to understand the details of a proof in Berglund's notes on rational homotopy theory (Thm 4.7 here https://staff.math.su.se/alexb/rathom2.pdf) which centers around extending a map into a $\mathbb{Q}$-local space along a rational equivalence. Here are the specifics of what I want to show. Suppose we have simply connected spaces $X,Y, Z$, a rational equivalence $r : X \rightarrow Z$ and map $f: X \rightarrow Y$. If $Y$ is a rational space then there is a $ \lambda : Z \to Y$ such that $f \simeq \lambda r$. In other words I want to show that $$r^* : [Z,Y] \rightarrow [X, Y]$$ is surjective for rational spaces $Y$.
The approach in these notes is to first show the statement holds for rational Eilenberg-Maclane spaces. Then for general rational spaces $Y$, we construct $\lambda$ inductively on the Postnikov tower of $Y$. Here is how that is done
I understand how this construction yields a map $\lambda : Z \rightarrow Y $, but I havent been able to show that $\lambda r \simeq f $. My intuition is telling me to construct the homotopy inductively as we construct $\lambda$. So lets suppose that we have compatible $H_i : X \times I \rightarrow Y_i$ defined for all $i < n$ witnessing $f_i \simeq \lambda_i r $. We have the following diagram
\begin{array}{ccccccccccc} X & \stackrel{f_n}{\to} & Y_n\\\ \downarrow & & \downarrow &\\ X\times I & \stackrel{H_{n-1}}{\to} & Y_{n-1} \end{array}
There is a lift for this diagram but it wont necessarily give us what we need. For instance, this lift is a homotopy from $f_i$ to some other map, but I don't see why this map would factor as $r$ followed by something. On the other hand if we first build $\lambda_i$, we would want to find a lift to the following diagram
\begin{array}{ccccccccccc} X \coprod X & \stackrel{f_n \coprod \lambda_n r}{\to} & Y_n\\\ \downarrow & & \downarrow &\\ X\times I & \stackrel{H_{n-1}}{\to} & Y_{n-1} \end{array}
but neither vertical map is a weak equivalence, so we cant appeal to abstract lifting properties of fibrations/cofibrations. Does anyone have any idea on how to construct this homotopy?

There is an answer using obstruction theory as Vincent Boelens suggests in the comments. Specifically, we can replace $r : X \to Z$ with a cofibration. Then since $r$ is a rational equivalence, $H^{n+1}(Z,X; \pi_n Y)=0$ because $\pi_n Y$ is rational. With this fact in mind we can appeal to cor. 4.73 in Hatcher.