Fallacy in the proof of Lebesgue theorem in the script On the lectures today, another professor came and told us there is a minor omission/mistake in the proof of one direction of the Lebesgue theorem, namely

$f:[a,b]\times[c,d]\to\Bbb R$ bounded and integrable implies $0$ measure set of discontinuities

that we might discuss when our professor returns, so I've been thinking about it as an exercise.
First, a definition and some results:
$\underline{\boldsymbol{\text{definition}}}$: Let $A\subset\Bbb R^2$ and $f:A\to\Bbb R$ any function. Oscillation $O(f,c)$ of the function $f$ at the point $c\in A$ is the infimum of the expression $\sup\{|f(x_1)-f(x_2)|:x_1,x_2\in U\cap A\}$ over all the open neighbourhoods $U\subset\Bbb R^2$ of the point $c$. In other words $$O(f,c)=\inf_{U\ni c}\sup_{x_1,x_2\in U\cap A}|f(x_1)-f(x_2)|.$$
$\underline{\boldsymbol{\text{ lemma }} 7.1}$:

A function $f:A\to\Bbb R$ is continuous at $c\in A$ if and only if $O(f,c)=0.$

$\underline{\boldsymbol{\text{result}}}$

If $D$ is the set of discontinuities of the function $f,$ then $D=\bigcup_{\varepsilon >0}D_\varepsilon,$ where $$D_\varepsilon=\{x\in A\mid O(f,c)\ge \varepsilon\}.$$

$\underline{\boldsymbol{\text{lemma } 7.5.}}$

Suppose $A$ is closed. For each $\varepsilon>0,\space D_\varepsilon$ is closed.

Here is the proof as written in the script:

Now, suppose that $f:[a,b]\times[c,d]\to\Bbb R$ is integrable and let $D$ be the set of all its discontinuities. Since $D=\bigcup_{n\in\Bbb N}D_{1/n}$ it is enough to show $D_{1/n}$ is of measure $0$ for all $n\in\Bbb N.$
For a given $\varepsilon>0,$ there is a partition $P$ of the rectangle $A=[a,b]\times[c,d]$ s. t. $U(P,f)- L(P,f)<\varepsilon.$ In particular, for the rectangles $A_{ij}$ that intersect $D_{1/n},$ it holds $\sum(M_{ij}-m_{ij})\nu(A_{ij})<\varepsilon,$ and, since $M_{ij}-m_{ij}\ge\frac1n$ for those rectangles $A_{ij},$ we see that the overall area of those rectangles is less than $n\varepsilon.$ Obviously, those rectangles cover $D_{1/n}.$
If $\varepsilon'>0$ is now arbitrary, we see that, with $\varepsilon=\frac{\varepsilon'}n,$ we've found finitely many rectangles which cover $D_{1/n}$ and whose overall area is less than $n\varepsilon=\varepsilon'$. Hence, $D_{1/n}$ is of Lebesgue measure $0$ (in fact, of Jordan measure $0$).

My attempt is that

since $M_{ij}-m_{ij}\ge\frac1n$ for those rectangles $A_{ij},$

is somewhat wrong. $A\subset\Bbb R^2$ is a closed rectangle and the rectangles $A_{ij}$ in the partition of $A$ are closed. If some of them intersect $D_{1/n},$ the intersection might be contained in their boundaries. For example, if we take the function $f:[0,2]\times[0,2]\to\Bbb R,$ $$f(x,y)=\begin{cases}1, x<1,\\2, x\ge 1\end{cases}$$ and take any suitable partition so that the segment $[(1,0),(1,2)]$ contains boundaries of some rectangles, they might be a counterexample.
I would like to ask if I'm on the right track and if we should isolate such cases?
 A: Let $D_{1/n}$ be the set of points in $[a,b]\times[c,d]$ such that the oscillation of $f$ is no smaller than $1/n$.  As you suspect,  if $D_{1/n}$ only meets a rectangle at the boundary $\partial A_{ij}$ then there is no guarantee  that $M_{ij} - m_{ij} \geqslant \frac{1}{n}$, and this is an impediment to the proof.  However, it is easy to fix.
There is a partition $P$ such that $U(P,f) - L(P,f) < \frac{\epsilon}{2n}$ and, thus
$$\tag{*}\frac{\epsilon}{2n}> \sum_{A_{ij}\in \mathcal{S}}(M_{ij}-m_{ij})\nu(A_{ij})+ \sum_{A_{ij}\in \mathcal{T}}(M_{ij}-m_{ij})\nu(A_{ij})+ \sum_{A_{ij}\in \mathcal{U}}(M_{ij}-m_{ij})\nu(A_{ij}),$$
where
$$\mathcal{S} = \{A_{ij}\, : \, D_{1/n} \cap \text{int}(A_{ij}) \neq \emptyset\},\\\mathcal{T} = \{A_{ij}\, : \, D_{1/n} \cap \text{int}(A_{ij}) = \emptyset,\,D_{1/n} \cap \partial A_{ij} \neq \emptyset\},\\ \mathcal{U} = \{A_{ij}\, : \, D_{1/n} \cap A_{ij} = \emptyset\}$$
So, $\mathcal{S}$ is the collection of partition rectangles with interiors that meet $D_{1/n}$ and $\mathcal{T}$ is the collection of partition rectangles with only boundaries meeting $D_{1/n}$.
Since each term on the RHS of (*) is nonnegative it follows that
$$\frac{\epsilon}{2n}> \sum_{A_{ij}\in \mathcal{S}}(M_{ij}-m_{ij})\nu(A_{ij})\geqslant \frac{1}{n}\sum_{A_{ij}\in \mathcal{S}}\nu(A_{ij}),$$
and  $\displaystyle\sum_{A_{ij}\in \mathcal{S}}\nu(A_{ij}) < \frac{\epsilon}{2}$.
The subset of points of $D_{1/n}$ that are in the interior of some rectangle $A_{ij}$ is covered by the rectangles in $\mathcal{S}$.  The remaining points of $D_{1/n}$, not in this subset, are found on the boundary of one or more rectangles.  The union of the all bounding faces is a set of measure zero and, as it is compact, a set of Jordan measure zero. Hence, there exists a finite collection of rectangles $\{B_k\}$ which cover these remaining points and with total volume less than $\frac{\epsilon}{2}$.
We then have
$$D_{1/n} \subset \bigcup_{A_{ij} \in \mathcal{S}}A_{ij} + \bigcup_{k} B_k, \quad \sum_{A_{ij} \in \mathcal{S}}\nu(A_{ij}) + \sum_{k} \nu(B_k) < \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon,$$
and $D_{1/n}$ has Jordan measure zero.
