Juanlu001: Ping @tomkralidis :) I found another potential issue but I'd prefer to submit the PRs one by one...!
diff --git a/src/pydap/responses/das.py b/src/pydap/responses/das.py
index 1b18516..43a2ecc 100644
--- a/src/pydap/responses/das.py
+++ b/src/pydap/responses/das.py
@@ -16,6 +16,8 @@ from collections import Iterable
 from six import string_types, integer_types
 from six.moves import map
 
+import numpy as np
+
 from ..model import (DatasetType, BaseType,
                      StructureType, SequenceType,
                      GridType)
@@ -88,8 +90,9 @@ def _basetypegridtype(var, level=0):
 
     for attr in sorted(var.attributes.keys()):
         values = var.attributes[attr]
-        for line in build_attributes(attr, values, level+1):
-            yield line
+        if np.asarray(values).size > 0:
+            for line in build_attributes(attr, values, level+1):
+                yield line
     yield '{indent}}}\n'.format(indent=level*INDENT)
 
 

Malformed DAS when missing data
I found a dataset which had a missing integer variable, and the resulting DAS contained a syntax error (see https://github.com/Unidata/netcdf4-python/issues/923 for my original report). This is the problematic line:

```
...
    VPED {
        ...
        Int32 WMO_code ;
    }
...
```

Comparing the output with Hyrax (see also https://github.com/OPENDAP/hyrax-docker/issues/6) it seems that Hyrax decides not to yield the line:

```diff
--- das_bad.txt	2019-05-04 13:06:06.779700399 +0200
+++ das_ok.txt	2019-05-04 13:04:13.721630474 +0200
@@ -1,19 +1,18 @@
     VPED {
         String long_name "Wave principal direction at spectral peak";
         String units "degree";
-        Float32 add_offset 180;
-        Float32 scale_factor 0.01;
+        Float32 add_offset 180.000000;
+        Float32 scale_factor 0.00999999978;
         Int16 _FillValue -32767;
         String standard_name "sea_surface_wave_from_direction_at_variance_spectral_density_maximum";
         String cell_methods "time:point area:mean";
         String type_of_analysis "spectral analysis";
-        Int32 WMO_code ;
     }
     VTM02 {
         String long_name "Spectral moments (0,2) wave period (Tm02)";
         String units "s";
-        Float32 add_offset 0;
-        Float32 scale_factor 0.01;
+        Float32 add_offset 0.00000000;
+        Float32 scale_factor 0.00999999978;
         Int16 _FillValue -32767;
         String standard_name "sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment";
         String cell_methods "time:point area:mean";
```

It turns out one single bad attribute invalidates all the DAS and netCDF4 cannot read the properties, in this case screwing up the decoding of the dates. Therefore, it might make sense to catch this type of situation and remove the faulty line.
diff --git a/src/pydap/tests/datasets.py b/src/pydap/tests/datasets.py
index 4e9be1e..b907630 100644
--- a/src/pydap/tests/datasets.py
+++ b/src/pydap/tests/datasets.py
@@ -179,3 +179,15 @@ SimpleGrid["x"] = SimpleGrid["SimpleGrid"]["x"] = BaseType(
     "x", np.arange(3), axis="X", units="degrees_east")
 SimpleGrid["y"] = SimpleGrid["SimpleGrid"]["y"] = BaseType(
     "y", np.arange(2), axis="Y", units="degrees_north")
+
+
+# a faulty grid
+FaultyGrid = DatasetType(
+    "FaultyGrid", description="A faulty grid for testing.")
+FaultyGrid["FaultyGrid"] = GridType("FaultyGrid")
+FaultyGrid["FaultyGrid"]["FaultyGrid"] = BaseType(
+    "FaultyGrid", np.arange(6).reshape(2, 3), dimensions=("y", "x"))
+FaultyGrid["x"] = FaultyGrid["FaultyGrid"]["x"] = BaseType(
+    "x", np.arange(3), axis="X", code=1)
+FaultyGrid["y"] = FaultyGrid["FaultyGrid"]["y"] = BaseType(
+    "y", np.arange(2), axis="Y", code=np.int32([]))
diff --git a/src/pydap/tests/test_responses_das.py b/src/pydap/tests/test_responses_das.py
index 95440fc..ff94533 100644
--- a/src/pydap/tests/test_responses_das.py
+++ b/src/pydap/tests/test_responses_das.py
@@ -4,7 +4,9 @@ from webtest import TestApp as App
 from webob.headers import ResponseHeaders
 from pydap.lib import __version__
 from pydap.handlers.lib import BaseHandler
-from pydap.tests.datasets import SimpleSequence, SimpleGrid, SimpleStructure
+from pydap.tests.datasets import (
+    SimpleSequence, SimpleGrid, FaultyGrid, SimpleStructure
+)
 from pydap.responses.das import das
 
 import unittest
@@ -107,6 +109,29 @@ class TestDASResponseGrid(unittest.TestCase):
 """)
 
 
+class TestDASResponseFaultyGrid(unittest.TestCase):
+
+    """Test the DAS response from a grid with empty properties."""
+
+    def test_body(self):
+        """Test the generated DAS response."""
+        app = App(BaseHandler(FaultyGrid))
+        res = app.get('/.das')
+        self.assertEqual(res.text, """Attributes {
+    String description "A faulty grid for testing.";
+    FaultyGrid {
+    }
+    x {
+        String axis "X";
+        Int32 code 1;
+    }
+    y {
+        String axis "Y";
+    }
+}
+""")
+
+
 class TestDASResponseStructure(unittest.TestCase):
 
     """The the DAS response from a structure."""

pip install -e .[testing]
parse_log_pytest
pytest
pytest pytest-cov pytest-attrib requests-mock WebTest flake8 werkzeug
apt-get update apt-get install -y libhdf5-serial-dev netcdf-bin libnetcdf-dev
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
beautifulsoup4==4.12.3
certifi==2021.5.30
cffi==1.15.1
cftime==1.6.0
charset-normalizer==2.0.12
coards==1.0.5
coverage==6.2
cryptography==40.0.2
dataclasses==0.8
docopt==0.6.2
flake8==5.0.4
gsw==3.0.6
gunicorn==21.2.0
idna==3.10
importlib-metadata==4.2.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.0.3
lxml==5.3.1
MarkupSafe==2.0.1
mccabe==0.7.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
netCDF4==1.6.2
numpy==1.19.5
ordereddict==1.1
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
PasteDeploy==2.1.1
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.9.1
pycparser==2.21
-e git+https://github.com/pydap/pydap.git@cbe37e2cbc0ede33c76344cfe438373a4adab3f3#egg=pydap
pyflakes==2.5.0
pyOpenSSL==23.2.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
pytest-attrib==0.1.3
pytest-cov==4.0.0
requests==2.27.1
requests-mock==1.12.1
six==1.17.0
soupsieve==2.3.2.post1
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli==1.2.3
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3==1.26.20
waitress==2.0.0
WebOb==1.8.9
WebTest==3.0.0
Werkzeug==2.0.3
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: pydap
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - beautifulsoup4==4.12.3
      - cffi==1.15.1
      - cftime==1.6.0
      - charset-normalizer==2.0.12
      - coards==1.0.5
      - coverage==6.2
      - cryptography==40.0.2
      - dataclasses==0.8
      - docopt==0.6.2
      - flake8==5.0.4
      - gsw==3.0.6
      - gunicorn==21.2.0
      - idna==3.10
      - importlib-metadata==4.2.0
      - jinja2==3.0.3
      - lxml==5.3.1
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - netcdf4==1.6.2
      - numpy==1.19.5
      - ordereddict==1.1
      - pastedeploy==2.1.1
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pyopenssl==23.2.0
      - pytest-attrib==0.1.3
      - pytest-cov==4.0.0
      - requests==2.27.1
      - requests-mock==1.12.1
      - six==1.17.0
      - soupsieve==2.3.2.post1
      - tomli==1.2.3
      - urllib3==1.26.20
      - waitress==2.0.0
      - webob==1.8.9
      - webtest==3.0.0
      - werkzeug==2.0.3
prefix: /opt/conda/envs/pydap

src/pydap/tests/test_responses_das.py::TestDASResponseFaultyGrid::test_body
src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_body src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_charset src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_content_type src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_dispatcher src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_headers src/pydap/tests/test_responses_das.py::TestDASResponseSequence::test_status src/pydap/tests/test_responses_das.py::TestDASResponseGrid::test_body src/pydap/tests/test_responses_das.py::TestDASResponseStructure::test_body
src/pydap/responses/das.py
src/pydap/responses/das.py