# Buggy code
def describe(self):
    result = {
        "jobDefinition": self.job_definition.arn,
        "jobId": self.job_id,
        "jobName": self.job_name,
        "jobQueue": self.job_queue.arn,
        "startedAt": datetime2int(self.job_started_at),
        "status": self.job_state,
        "dependsOn": [],
    }
    if self.job_stopped:
        result["stoppedAt"] = datetime2int(self.job_stopped_at)
        result["container"] = {}
        result["container"]["command"] = [
            '/bin/sh -c "for a in `seq 1 10`; do echo Hello World; sleep 1; done"'
        ]
        result["container"]["privileged"] = False
        result["container"]["readonlyRootFilesystem"] = False
        result["container"]["ulimits"] = {}
        result["container"]["vcpus"] = 1
        result["container"]["volumes"] = ""
        result["container"]["logStreamName"] = self.log_stream_name
    if self.job_stopped_reason is not None:
        result["statusReason"] = self.job_stopped_reason
    return result


# Traceback (AttributeError)
2020-02-28 23:16:27 - werkzeug     - INFO     - 127.0.0.1 - - [28/Feb/2020 23:16:27] "POST /v1/describejobs HTTP/1.1" 500 -
2020-02-28 23:16:27 - werkzeug     - ERROR    - Error on request:
Traceback (most recent call last):
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/server.py", line 135, in __call__
return backend_app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/utils.py", line 144, in __call__
result = self.callback(request, request.url, {})
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 197, in dispatch
return cls()._dispatch(*args, **kwargs)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 295, in _dispatch
return self.call_action()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 380, in call_action
response = method()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/responses.py", line 257, in describejobs
return json.dumps({"jobs": self.batch_backend.describe_jobs(jobs)})
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/models.py", line 1229, in describe_jobs
result.append(job.describe())
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/models.py", line 355, in describe
result["container"]["logStreamName"] = self.log_stream_name
AttributeError: 'Job' object has no attribute 'log_stream_name'

# Fixed code
def describe(self):
    result = {
        "jobDefinition": self.job_definition.arn,
        "jobId": self.job_id,
        "jobName": self.job_name,
        "jobQueue": self.job_queue.arn,
        "status": self.job_state,
        "dependsOn": [],
    }
    if result["status"] not in ["SUBMITTED", "PENDING", "RUNNABLE", "STARTING"]:
        result["startedAt"] = datetime2int(self.job_started_at)
    if self.job_stopped:
        result["stoppedAt"] = datetime2int(self.job_stopped_at)
        result["container"] = {}
        result["container"]["command"] = [
            '/bin/sh -c "for a in `seq 1 10`; do echo Hello World; sleep 1; done"'
        ]
        result["container"]["privileged"] = False
        result["container"]["readonlyRootFilesystem"] = False
        result["container"]["ulimits"] = {}
        result["container"]["vcpus"] = 1
        result["container"]["volumes"] = ""
        result["container"]["logStreamName"] = self.log_stream_name
    if self.job_stopped_reason is not None:
        result["statusReason"] = self.job_stopped_reason
    return result