Confusion in deriving Gauss law for magnetism

I am deriving Gauss law for magnetism from Coulomb's law of magnetic poles. I have a cubical magnet as shown below and the Gaussian surface is inside the magnet: The magnet can be considered as a group of a large number of infinitesimal magnetic dipoles.

Now from Gauss flux law, the flux due to infinitesimal magnetic dipoles inside and outside the Gaussian surface will be apparently zero.

Now magnetic field at a point on the Gaussian surface due to an infinitesimal dipole at that point is indeterminate. Therefore, the flux over the Gaussian surface due to infinitesimal dipole on the Gaussian surface will be indeterminate. Similarly,the flux over the Gaussian surface due to all infinitesimal dipoles on the Gaussian surface will be indeterminate. So our net result would be:

$$\text{Zero}_{\text{(inside)}}+\text{Zero}_{\text{(outside)}}+\text{Indeterminate}_{(\text{on the Gaussian surface})}=\text{Indeterminate}$$

But it must be zero. Where have I gone wrong?

• Why are you considering surfaces which intersect points where the magnetic field is undefined? – J. Murray Sep 24 '18 at 18:56
• I wanted to visualize $\nabla.\vec{B}=\dfrac{d \phi}{dV}$ at a point inside the magnet. So I took a small volume inside the magnet. – N.G.Tyson Sep 24 '18 at 19:13
• As a side note, I don't think that anything in this style can really constitute a general proof of Gauss's law for magnetism. We can have magnetic fields that can't be generated by a distribution of infinitesimal dipoles. One example would be a magnetic field that is uniform everywhere. Another example would be an electromagnetic wave packet traveling in a vacuum. – Ben Crowell Sep 24 '18 at 21:35