Exception handling between services and temporal

I have a shared library between my workflow implementations and activity implementation. They are defined in different services for our project.

If I throw an exception from the ActivityImpl suppose DataNotFoundException:

   if (data == null) {
        String errorMessage = String.format("some-error-message");
        throw new DataNotFoundException(errorMessage);
      }

In my workflow implementation, I have added DataNotFoundException as a DoNotRetry option but still the workflow retries to the number specified in MaxAttempts before workflow failure.

I want the MaxAttempts fields to be respected but not for the said exception. What am I missing here?