This question stems from the exercise 2.50 of Griffith's Introduction to Electrodynamics, which I am rereading.
In the problem, he asks to find the charge density of a volume when the electric field is
$\textbf{E}(x,y,z) = ax\space \hat{x}$
And to find a possible explanation as to why the electric field would point in that particular direction.
We can easily show that electric field corresponds to a uniform charge density, but it is not simple to explain why, then, a uniform charge density would give rise to such an electric field.
If we want to answer why the field is oriented along the x axis instead of any other, we can argue that knowing the divergence and rotational of a field is not sufficient to determine it uniquely, and thus, a uniform charge density definitely could give rise to, say, $\textbf{E}(x,y,z) = ay\space \hat{y}$. This ambiguity would be lifted by the appropriate boundary conditions, which is trivial, in a way.
What I cannot grasp at all is how, if we consider a non-zero infinite distribution, these results even make sense. Due to rotational and translational symmetry, an infinite uniform charge density should give rise to no electric field. However, if we calculate the divergence of a null field, we get $\nabla \cdot\textbf{E}(x,y,z) = 0$ instead, which would require $\rho = 0$, in contradiction with our initial assumption.
I have tried to use Gauss's law to analyse the problem, but I reach a similar nonesensical answer: Consider a sphere in this infinite charge distribution, as well a spherical shell that touches the surface of the sphere and has infinite thickness (you can also consider an infinite number of shells with finite thickness that fill the whole space). From Gauss's law, the electric field the shell creates in the surface of the sphere is zero, while the electric field created by the sphere is proportional to its charge. Thus, the electric field in the surface of the sphere is radial and non-zero, in contradiction once again with symmetry arguments.
What is going on here?