Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Error on Object deletion. #2621

Closed
martink2 opened this issue Nov 28, 2018 · 8 comments
Closed

Server Error on Object deletion. #2621

martink2 opened this issue Nov 28, 2018 · 8 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@martink2
Copy link

Environment

  • Python version: v3.5.2
  • NetBox version: v2.4.6

Steps to Reproduce

My users are reporting that they get intermittent errors deleting or manipulating objects.
They get those errors for a couple of minutes and after a couple of minutes the delete operations working fine.

Expected Behavior

The operation should not produce a internal server error.

Observed Behavior

Please find the error info generated when this happens.

Internal Server Error: /dcim/devices/1560/delete/

ValueError at /dcim/devices/1560/delete/
Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c58913c8>": "ObjectChange.user" must be a "User" instance.

Request Method: POST
Request URL: https://******/dcim/devices/1560/delete/
Django Version: 2.0.9
Python Executable: /usr/bin/python3
Python Version: 3.5.2
Python Path: ['/opt/netbox/netbox', '/usr/local/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Wed, 28 Nov 2018 10:02:42 +0000
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'corsheaders',
'debug_toolbar',
'django_filters',
'django_tables2',
'mptt',
'rest_framework',
'taggit',
'taggit_serializer',
'timezone_field',
'circuits',
'dcim',
'ipam',
'extras',
'secrets',
'tenancy',
'users',
'utilities',
'virtualization',
'drf_yasg']
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'utilities.middleware.ExceptionHandlingMiddleware',
'utilities.middleware.LoginRequiredMiddleware',
'utilities.middleware.APIVersionMiddleware',
'extras.middleware.ObjectChangeMiddleware')


Traceback:

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/mixins.py" in dispatch
  85.         return super().dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in post
  280.                 obj.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in delete
  891.         return collector.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/deletion.py" in delete
  307.                             sender=model, instance=obj, using=self.using

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in send
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in <listcomp>
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py" in _curried
  11.         return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs))

File "/opt/netbox/netbox/extras/middleware.py" in _record_object_deleted
  37.         instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE)

File "/opt/netbox/netbox/dcim/models.py" in log_change
  53.             object_data=serialize_object(self)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in __init__
  477.                     _setattr(self, field.name, rel_obj)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in __set__
  197.                     self.field.remote_field.model._meta.object_name,

Exception Type: ValueError at /dcim/devices/1560/delete/
Exception Value: Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c58913c8>": "ObjectChange.user" must be a "User" instance.
Request information:
USER: d030973

GET: No GET data

POST:
_confirm = ''
csrfmiddlewaretoken = 'KmqqTvgwzElKzc4roJbhKzgikIo4IeCoGFMbiN8HOdHEEx1bRQYfmG8gLPSXf8OY'
return_url = ''
confirm = 'True'

FILES: No FILES data

COOKIES:
csrftoken = 'wuhIYpVN3GaToyqRY6ddw5qWfWbwDa9WsNDtnHNYifwNtTnBrd0b8ciUG3Fpa4lw'
sessionid = '0nhtm3k9xg79rca5xejnmcftyb25crlb'

META:
CONTENT_LENGTH = '119'
CONTENT_TYPE = 'application/x-www-form-urlencoded'
CSRF_COOKIE = 'wuhIYpVN3GaToyqRY6ddw5qWfWbwDa9WsNDtnHNYifwNtTnBrd0b8ciUG3Fpa4lw'
HTTP_ACCEPT = 'text/html, application/xhtml+xml, image/jxr, */*'
HTTP_ACCEPT_ENCODING = 'gzip, deflate'
HTTP_ACCEPT_LANGUAGE = 'de-DE'
HTTP_CACHE_CONTROL = 'no-cache'
HTTP_CONNECTION = 'close'
HTTP_COOKIE = 'csrftoken=wuhIYpVN3GaToyqRY6ddw5qWfWbwDa9WsNDtnHNYifwNtTnBrd0b8ciUG3Fpa4lw; sessionid=0nhtm3k9xg79rca5xejnmcftyb25crlb'
HTTP_HOST = '127.0.0.1:8001'
HTTP_REFERER = 'https://******/dcim/devices/1560/delete/'
HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko'
HTTP_X_FORWARDED_HOST = '******'
HTTP_X_FORWARDED_PROTO = 'https'
HTTP_X_REAL_IP = '10.88.140.206'
PATH_INFO = '/dcim/devices/1560/delete/'
QUERY_STRING = ''
RAW_URI = '/dcim/devices/1560/delete/'
REMOTE_ADDR = '127.0.0.1'
REMOTE_PORT = '49032'
REQUEST_METHOD = 'POST'
SCRIPT_NAME = ''
SERVER_NAME = '127.0.0.1'
SERVER_PORT = '8001'
SERVER_PROTOCOL = 'HTTP/1.0'
SERVER_SOFTWARE = 'gunicorn/19.9.0'
gunicorn.socket = <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8001), raddr=('127.0.0.1', 49032)>
wsgi.errors = <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f91bf841c50>
wsgi.file_wrapper = ''
wsgi.input = <gunicorn.http.body.Body object at 0x7f91bf841cf8>
wsgi.multiprocess = True
wsgi.multithread = False
wsgi.run_once = False
wsgi.url_scheme = 'https'
wsgi.version = '(1, 0)'

Settings:
Using settings module netbox.settings
ABSOLUTE_URL_OVERRIDES = {}
ADMINS = [['******', '******']]
ALLOWED_HOSTS = ['10.67.74.97', '******']
APPEND_SLASH = True
AUTHENTICATION_BACKENDS = ['django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend']
AUTH_LDAP_BIND_DN = 'CN=netbox-service,CN=Users,DC=ad,DC=global,DC=cloud,DC=sap'
AUTH_LDAP_BIND_PASSWORD = '********************'
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_CONNECTION_OPTIONS = {8: 0}
AUTH_LDAP_FIND_GROUP_PERMS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
AUTH_LDAP_GROUP_SEARCH = <LDAPSearch: OU=Permissions,OU=CCloud,DC=ad,DC=global,DC=cloud,DC=sap>
AUTH_LDAP_GROUP_TYPE = <django_auth_ldap.config.NestedGroupOfNamesType object at 0x7f91d8755710>
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_REQUIRE_GROUP = 'CN=CP_CONV_NETBOX_USE,OU=Permissions,OU=CCloud,DC=ad,DC=global,DC=cloud,DC=sap'
AUTH_LDAP_SERVER_URI = 'ldaps://ldap.global.cloud.sap'
AUTH_LDAP_USER_ATTR_MAP = {'last_name': 'sn', 'first_name': 'givenName'}
AUTH_LDAP_USER_DN_TEMPLATE = None
AUTH_LDAP_USER_FLAGS_BY_GROUP = {'is_active': 'CN=CP_CONV_NETBOX_USE,OU=Permissions,OU=CCloud,DC=ad,DC=global,DC=cloud,DC=sap'}
AUTH_LDAP_USER_SEARCH = <LDAPSearch: OU=Identities,DC=ad,DC=global,DC=cloud,DC=sap>
AUTH_PASSWORD_VALIDATORS = '********************'
AUTH_USER_MODEL = 'auth.User'
BANNER_BOTTOM = ''
BANNER_LOGIN = ''
BANNER_TOP = ''
BASE_DIR = '/opt/netbox/netbox'
BASE_PATH = ''
CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_KEY_PREFIX = '********************'
CACHE_MIDDLEWARE_SECONDS = 600
CHANGELOG_RETENTION = 0
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_REGEX_WHITELIST = []
CORS_ORIGIN_WHITELIST = []
CSRF_COOKIE_AGE = 31449600
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME = 'csrftoken'
CSRF_COOKIE_PATH = '/'
CSRF_COOKIE_SECURE = False
CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS = ['10.67.74.97', '******']
CSRF_USE_SESSIONS = False
DATABASE = {'OPTIONS': {}, 'CONN_MAX_AGE': 0, 'HOST': 'localhost', 'NAME': 'netbox', 'PORT': '', 'PASSWORD': '********************', 'USER': 'netbox', 'TIME_ZONE': None, 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'TEST': {'NAME': None, 'COLLATION': None, 'CHARSET': None, 'MIRROR': None}, 'ENGINE': 'django.db.backends.postgresql'}
DATABASES = {'default': {'OPTIONS': {}, 'CONN_MAX_AGE': 0, 'HOST': 'localhost', 'NAME': 'netbox', 'PORT': '', 'PASSWORD': '********************', 'USER': 'netbox', 'TIME_ZONE': None, 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'TEST': {'NAME': None, 'COLLATION': None, 'CHARSET': None, 'MIRROR': None}, 'ENGINE': 'django.db.backends.postgresql'}}
DATABASE_ROUTERS = []
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
DATETIME_FORMAT = 'N j, Y g:i a'
DATETIME_INPUT_FORMATS = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M', '%m/%d/%y']
DATE_FORMAT = 'N j, Y'
DATE_INPUT_FORMATS = ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y']
DEBUG = False
DEBUG_PROPAGATE_EXCEPTIONS = False
DECIMAL_SEPARATOR = '.'
DEFAULT_CHARSET = 'utf-8'
DEFAULT_CONTENT_TYPE = 'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE = ''
DEFAULT_TABLESPACE = ''
DISALLOWED_USER_AGENTS = []
EMAIL = {'PORT': 25, 'SERVER': 'mail.sap.corp', 'USERNAME': '', 'TIMEOUT': 10, 'PASSWORD': '********************', 'FROM_EMAIL': 'test@sap.corp'}
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.sap.corp'
EMAIL_HOST_PASSWORD = '********************'
EMAIL_HOST_USER = ''
EMAIL_PORT = 25
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = '********************'
EMAIL_SUBJECT_PREFIX = '[NetBox] '
EMAIL_TIMEOUT = 10
EMAIL_USE_LOCALTIME = False
EMAIL_USE_SSL = False
EMAIL_USE_TLS = False
ENFORCE_GLOBAL_UNIQUE = False
FILE_CHARSET = 'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_TEMP_DIR = None
FILTERS_NULL_CHOICE_LABEL = 'None'
FILTERS_NULL_CHOICE_VALUE = '0'
FIRST_DAY_OF_WEEK = 0
FIXTURE_DIRS = []
FORCE_SCRIPT_NAME = None
FORMAT_MODULE_PATH = None
FORM_RENDERER = 'django.forms.renderers.DjangoTemplates'
HOSTNAME = '******'
IGNORABLE_404_URLS = []
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_tables2', 'mptt', 'rest_framework', 'taggit', 'taggit_serializer', 'timezone_field', 'circuits', 'dcim', 'ipam', 'extras', 'secrets', 'tenancy', 'users', 'utilities', 'virtualization', 'drf_yasg']
INTERNAL_IPS = "('127.0.0.1', '::1')"
LANGUAGES = [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')]
LANGUAGES_BIDI = ['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_NAME = 'django_language'
LANGUAGE_COOKIE_PATH = '/'
LDAP_CONFIGURED = True
LDAP_IGNORE_CERT_ERRORS = True
LOCALE_PATHS = []
LOGGING = {}
LOGGING_CONFIG = 'logging.config.dictConfig'
LOGIN_REDIRECT_URL = '/accounts/profile/'
LOGIN_REQUIRED = False
LOGIN_URL = '/login/'
LOGOUT_REDIRECT_URL = None
MAINTENANCE_MODE = False
MANAGERS = []
MAX_PAGE_SIZE = 0
MEDIA_ROOT = '/opt/netbox/netbox/media'
MEDIA_URL = '/media/'
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
MESSAGE_TAGS = {40: 'danger'}
MIDDLEWARE = "('debug_toolbar.middleware.DebugToolbarMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'utilities.middleware.ExceptionHandlingMiddleware', 'utilities.middleware.LoginRequiredMiddleware', 'utilities.middleware.APIVersionMiddleware', 'extras.middleware.ObjectChangeMiddleware')"
MIGRATION_MODULES = {}
MONTH_DAY_FORMAT = 'F j'
NAPALM_ARGS = {}
NAPALM_PASSWORD = '********************'
NAPALM_TIMEOUT = 30
NAPALM_USERNAME = ''
NUMBER_GROUPING = 0
PAGINATE_COUNT = 50
PASSWORD_HASHERS = '********************'
PASSWORD_RESET_TIMEOUT_DAYS = '********************'
PREFER_IPV4 = True
PREPEND_WWW = False
REDIS = {'PORT': 6379, 'HOST': 'localhost', 'DEFAULT_TIMEOUT': 300, 'PASSWORD': '********************', 'DATABASE': 0}
REDIS_DATABASE = 0
REDIS_DEFAULT_TIMEOUT = 300
REDIS_HOST = 'localhost'
REDIS_PASSWORD = '********************'
REDIS_PORT = 6379
REPORTS_ROOT = '/opt/netbox-reports'
REST_FRAMEWORK = {'DEFAULT_PAGINATION_CLASS': 'netbox.api.OptionalLimitOffsetPagination', 'VIEW_NAME_FUNCTION': 'netbox.api.get_view_name', 'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer', 'netbox.api.FormlessBrowsableAPIRenderer'), 'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication', 'netbox.api.TokenAuthentication'), 'PAGE_SIZE': 50, 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning', 'DEFAULT_VERSION': '2.4', 'ALLOWED_VERSIONS': ['2.4'], 'DEFAULT_PERMISSION_CLASSES': ('netbox.api.TokenPermissions',), 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',)}
REST_FRAMEWORK_VERSION = '2.4'
ROOT_URLCONF = 'netbox.urls'
RQ_QUEUES = {'default': {'PORT': 6379, 'HOST': 'localhost', 'DEFAULT_TIMEOUT': 300, 'PASSWORD': '********************', 'DB': 0}}
SECRETS_MIN_PUBKEY_SIZE = '********************'
SECRET_KEY = '********************'
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_PROXY_SSL_HEADER = "('HTTP_X_FORWARDED_PROTO', 'https')"
SECURE_REDIRECT_EXEMPT = []
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False
SERVER_EMAIL = 'test@sap.corp'
SESSION_CACHE_ALIAS = 'default'
SESSION_COOKIE_AGE = 1209600
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = 'sessionid'
SESSION_COOKIE_PATH = '/'
SESSION_COOKIE_SECURE = False
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_FILE_PATH = None
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE = 'netbox.settings'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
SHORT_DATE_FORMAT = 'Y-m-d'
SHORT_TIME_FORMAT = 'H:i:s'
SIGNING_BACKEND = 'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS = []
STATICFILES_DIRS = "('/opt/netbox/netbox/project-static',)"
STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = '/opt/netbox/netbox/static/'
STATIC_URL = '/static/'
SWAGGER_SETTINGS = {'DEFAULT_FIELD_INSPECTORS': ['utilities.custom_inspectors.NullableBooleanFieldInspector', 'utilities.custom_inspectors.CustomChoiceFieldInspector', 'drf_yasg.inspectors.CamelCaseJSONFilter', 'drf_yasg.inspectors.ReferencingSerializerInspector', 'drf_yasg.inspectors.RelatedFieldInspector', 'drf_yasg.inspectors.ChoiceFieldInspector', 'drf_yasg.inspectors.FileFieldInspector', 'drf_yasg.inspectors.DictFieldInspector', 'drf_yasg.inspectors.SimpleFieldInspector', 'drf_yasg.inspectors.StringDefaultFieldInspector'], 'VALIDATOR_URL': None, 'DEFAULT_FILTER_INSPECTORS': ['utilities.custom_inspectors.IdInFilterInspector', 'drf_yasg.inspectors.CoreAPICompatInspector'], 'SECURITY_DEFINITIONS': {'Bearer': {'in': 'header', 'name': 'Authorization', 'type': 'apiKey'}}, 'DEFAULT_PAGINATOR_INSPECTORS': ['utilities.custom_inspectors.NullablePaginatorInspector', 'drf_yasg.inspectors.DjangoRestResponsePagination', 'drf_yasg.inspectors.CoreAPICompatInspector']}
TEMPLATES = [{'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.template.context_processors.media', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'utilities.context_processors.settings']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/opt/netbox/netbox/templates/'], 'APP_DIRS': True}]
TEST_NON_SERIALIZED_APPS = []
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR = ','
TIME_FORMAT = 'g:i a'
TIME_INPUT_FORMATS = ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE = 'UTC'
USE_ETAGS = False
USE_I18N = True
USE_L10N = False
USE_THOUSAND_SEPARATOR = False
USE_TZ = True
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = False
VERSION = '2.4.6'
WEBHOOKS_ENABLED = False
WSGI_APPLICATION = 'netbox.wsgi.application'
X_FRAME_OPTIONS = 'SAMEORIGIN'
YEAR_MONTH_FORMAT = 'F Y'
@jeremystretch
Copy link
Member

Please post the steps someone else can take to recreate this issue.

@jeremystretch jeremystretch added the status: revisions needed This issue requires additional information to be actionable label Nov 28, 2018
@martink2
Copy link
Author

martink2 commented Nov 28, 2018

The problem is i cannot re-create the issue on demand ... yet.
I just have a lot of user complaints and get around 10 to 15
errors a day like the above mailed to me on a mildly used installation.

So during normal operations from time to time my users get a server error like the above
when deleting objects or inventory items.

@jeremystretch
Copy link
Member

Closing this out for now as it is not actionable. Please request to have it re-opened if you are able to reliably reproduce the issue.

@jeremystretch jeremystretch removed the status: revisions needed This issue requires additional information to be actionable label Nov 30, 2018
@jeremystretch jeremystretch reopened this Apr 18, 2019
@jeremystretch
Copy link
Member

Re-opening this because it's the earliest report of a symptom which I believe is related to somewhat-randomly recurring bug. It seems that the changelog middleware has been running into the issue described here, where the user associated with the request is not authenticated prior to being captured for the ObjectChange being recorded.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Apr 18, 2019
@lampwins
Copy link
Contributor

In an effort to document our findings, we noticed develop-2.6 is not experiencing this issue. I ran an overnight endurance test to confirm this. The code changes we tried in #3081, unfortunately, did not work so we investigated what is different in develop-2.6. Upgrading the Django dependancy to 2.2 is only noticeable change so I reran my endurance test again with 2.2 in develop with great success.

At this point, we don't have a root cause but we know upgrading to Django 2.2 fixes the problem. Unfortunately, the release notes, don't seem to mention anything related.

So the question is do we pin develop to Django 2.2 or match the looser dependancy defined in develop-2.6? @jeremystretch do you know of any other Django changes that would make this problematic?

@jeremystretch
Copy link
Member

I don't believe upgrading to Django 2.2 required any changes to NetBox. I think it's reasonable to have the 2.5 train match Django>=2.2,<2.3 to fix this issue.

@a31amit
Copy link

a31amit commented Jul 22, 2019

I think this bug still exists in 2.6.1. I found intermittent failure in Delete operations.

Internal Server Error: /api/dcim/interfaces/29089/
Internal Server Error: /api/dcim/devices/1860/
Internal Server Error: /api/dcim/devices/1865/
Internal Server Error: /api/dcim/devices/1863/
Internal Server Error: /api/ipam/ip-addresses/9202/
Internal Server Error: /api/dcim/devices/1858/
Internal Server Error: /api/dcim/devices/1859/
Internal Server Error: /api/dcim/inventory-items/130823/
Internal Server Error: /api/dcim/devices/1871/
Internal Server Error: /api/dcim/inventory-items/130826/
Internal Server Error: /api/dcim/interfaces/29123/
Internal Server Error: /api/dcim/devices/2007/
Internal Server Error: /api/dcim/devices/2008/
Internal Server Error: /api/dcim/devices/1995/
Internal Server Error: /api/dcim/inventory-items/131278/
Internal Server Error: /api/dcim/devices/2012/
Internal Server Error: /api/dcim/devices/2016/```


[22/Jul/2019 13:23:31] "GET /api/ipam/ip-addresses/?interface_id=29138 HTTP/1.1" 200 52
Internal Server Error: /api/dcim/devices/2016/
Traceback (most recent call last):
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/viewsets.py", line 116, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox-2.6.1/netbox/utilities/api.py", line 279, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/mixins.py", line 93, in destroy
    self.perform_destroy(instance)
  File "/opt/netbox/python37/lib/python3.7/site-packages/rest_framework/mixins.py", line 97, in perform_destroy
    instance.delete()
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/db/models/base.py", line 919, in delete
    return collector.delete()
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/db/models/deletion.py", line 318, in delete
    sender=model, instance=obj, using=self.using
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in send
    for receiver in self._live_receivers(sender)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/utils/functional.py", line 14, in _curried
    return _curried_func(*args, *moreargs, **{**kwargs, **morekwargs})
  File "/opt/netbox/netbox-2.6.1/netbox/extras/middleware.py", line 35, in _record_object_deleted
    instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE)
  File "/opt/netbox/netbox-2.6.1/netbox/utilities/models.py", line 36, in log_change
    object_data=serialize_object(self)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/db/models/base.py", line 483, in __init__
    _setattr(self, field.name, rel_obj)
  File "/opt/netbox/python37/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 211, in __set__
    self.field.remote_field.model._meta.object_name,
ValueError: Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7f1ad13af048>>": "ObjectChange.user" must be a "User" instance.
[22/Jul/2019 13:23:31] "DELETE /api/dcim/devices/2016/ HTTP/1.1" 500 23771```

@netbox-community netbox-community deleted a comment from juan-vg Sep 23, 2019
@jeremystretch
Copy link
Member

This issue pertains to an old release of NetBox and has been resolved. If you experience similar issues on the current stable release of NetBox, please open a new issue.

@netbox-community netbox-community locked as resolved and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants