Find the range of $\theta$ for the portion of line $y=x-1$ in the range $0\le x \le \infty$.
I was trying: Let: $y=x-1$ in polar form: \begin{align*} x &= r \cos\theta \\ y &= r \sin\theta \\ r &=\frac{1}{\cos\theta-\sin\theta}. \end{align*}
We see that when $\theta = \pi/4$, $r$ is undefined. And we reach a maximum at $\theta = 0$?
$$\pi/4<\theta<0$$
for the portion of the line this is wrong
The polar formula is good, but you got the range of $\theta$ wrong. The line starts at point $(-1,0)$, which has polar coordinates $r=1,\theta=-\pi/2$; then it moves upward away from the origin. Every ray springing from the origin, which is a set of the form $\{\theta=\theta_0\}$ with $\theta_0>-\pi/2$, intersects the line, as long as $\theta_0<\pi/4$, because $\theta=\pi/4$ is a ray parallel to the line (slope $=1$). Therefore, the correct range is $-\pi/2 < \theta < \pi/4$.
(Of course, you can add $2\pi$ to both endpoints and get another valid range, but I'm choosing to let $\theta\in(-\pi,\pi)$.)