[GH-ISSUE #38] Secret key not being set; can't create new records in admin #22

Closed
opened 2026-02-26 01:32:55 +03:00 by kerem · 3 comments
Owner

Originally created by @Datamance on GitHub (Jul 31, 2016).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/38

See stacktrace:

127.0.0.1 - - [30/Jul/2016 20:10:12] "GET /admin/proposals/new/?url=%2Fadmin%2Fproposals%2F HTTP/1.1" 200 -
[2016-07-30 20:10:38,291] ERROR in app: Exception on /admin/proposals/new/ [POST]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/contrib/sqla/view.py", line 1026, in create_model
    self.session.commit()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/scoping.py", line 157, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 811, in commit
    self.transaction.commit()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 398, in commit
    self._prepare_impl()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 378, in _prepare_impl
    self.session.flush()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2065, in flush
    self._flush(objects)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2183, in _flush
    transaction.rollback(_capture_exception=True)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2147, in _flush
    flush_context.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 386, in execute
    rec.execute(self)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 545, in execute
    uow
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 176, in save_obj
    mapper, table, insert)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 812, in _emit_insert_statements
    execute(statement, params)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 947, in execute
    return meth(self, multiparams, params)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 262, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1040, in _execute_clauseelement
    if not self.schema_for_object.is_default else None
  File "<string>", line 1, in <lambda>
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 433, in compile
    return self._compiler(dialect, bind=bind, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 439, in _compiler
    return dialect.statement_compiler(dialect, self, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 421, in __init__
    Compiled.__init__(self, dialect, statement, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 208, in __init__
    self.string = self.process(self.statement, **compile_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 231, in process
    return obj._compiler_dispatch(self, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
    return meth(self, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 1927, in visit_insert
    self, insert_stmt, crud.ISINSERT, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 56, in _setup_crud_params
    return _get_crud_params(compiler, stmt, **kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 135, in _get_crud_params
    _col_bind_name, check_columns, values, kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 280, in _scan_cols
    compiler, stmt, c, values, kw)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 380, in _append_param_insert_pk_returning
    _raise_pk_with_no_anticipated_value(c)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 681, in _raise_pk_with_no_anticipated_value
    raise exc.CompileError(msg)
sqlalchemy.exc.CompileError: Column 'proposals.id' is marked as a member of the primary key for table 'proposals', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed.  Primary key columns typically may not store NULL.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/base.py", line 69, in inner
    return self._run_view(f, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/base.py", line 368, in _run_view
    return fn(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/model/base.py", line 1920, in create_view
    model = self.create_model(form)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/contrib/sqla/view.py", line 1029, in create_model
    flash(gettext('Failed to create record. %(error)s', error=str(ex)), 'error')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/helpers.py", line 386, in flash
    session['_flashes'] = flashes
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/werkzeug/local.py", line 346, in __setitem__
    self._get_current_object()[key] = value
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/sessions.py", line 126, in _fail
    raise RuntimeError('The session is unavailable because no secret '
RuntimeError: The session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.

Not sure if the secret key wasn't set because of sqlalchemy's CompileError or what, but it's unclear how I can get around this currently.

Originally created by @Datamance on GitHub (Jul 31, 2016). Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/38 See stacktrace: ``` 127.0.0.1 - - [30/Jul/2016 20:10:12] "GET /admin/proposals/new/?url=%2Fadmin%2Fproposals%2F HTTP/1.1" 200 - [2016-07-30 20:10:38,291] ERROR in app: Exception on /admin/proposals/new/ [POST] Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/contrib/sqla/view.py", line 1026, in create_model self.session.commit() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/scoping.py", line 157, in do return getattr(self.registry(), name)(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 811, in commit self.transaction.commit() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 398, in commit self._prepare_impl() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 378, in _prepare_impl self.session.flush() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2065, in flush self._flush(objects) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2183, in _flush transaction.rollback(_capture_exception=True) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 186, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 2147, in _flush flush_context.execute() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 386, in execute rec.execute(self) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/unitofwork.py", line 545, in execute uow File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 176, in save_obj mapper, table, insert) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/orm/persistence.py", line 812, in _emit_insert_statements execute(statement, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 947, in execute return meth(self, multiparams, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 262, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1040, in _execute_clauseelement if not self.schema_for_object.is_default else None File "<string>", line 1, in <lambda> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 433, in compile return self._compiler(dialect, bind=bind, **kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 439, in _compiler return dialect.statement_compiler(dialect, self, **kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 421, in __init__ Compiled.__init__(self, dialect, statement, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 208, in __init__ self.string = self.process(self.statement, **compile_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 231, in process return obj._compiler_dispatch(self, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch return meth(self, **kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py", line 1927, in visit_insert self, insert_stmt, crud.ISINSERT, **kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 56, in _setup_crud_params return _get_crud_params(compiler, stmt, **kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 135, in _get_crud_params _col_bind_name, check_columns, values, kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 280, in _scan_cols compiler, stmt, c, values, kw) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 380, in _append_param_insert_pk_returning _raise_pk_with_no_anticipated_value(c) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sqlalchemy/sql/crud.py", line 681, in _raise_pk_with_no_anticipated_value raise exc.CompileError(msg) sqlalchemy.exc.CompileError: Column 'proposals.id' is marked as a member of the primary key for table 'proposals', but has no Python-side or server-side default generator indicated, nor does it indicate 'autoincrement=True' or 'nullable=True', and no explicit value is passed. Primary key columns typically may not store NULL. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app response = self.full_dispatch_request() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request rv = self.handle_user_exception(e) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request rv = self.dispatch_request() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/app.py", line 1625, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/base.py", line 69, in inner return self._run_view(f, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/base.py", line 368, in _run_view return fn(self, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/model/base.py", line 1920, in create_view model = self.create_model(form) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask_admin/contrib/sqla/view.py", line 1029, in create_model flash(gettext('Failed to create record. %(error)s', error=str(ex)), 'error') File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/helpers.py", line 386, in flash session['_flashes'] = flashes File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/werkzeug/local.py", line 346, in __setitem__ self._get_current_object()[key] = value File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/flask/sessions.py", line 126, in _fail raise RuntimeError('The session is unavailable because no secret ' RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret. ``` Not sure if the secret key wasn't set because of sqlalchemy's CompileError or what, but it's unclear how I can get around this currently.
kerem closed this issue 2026-02-26 01:32:55 +03:00
Author
Owner

@Datamance commented on GitHub (Jul 31, 2016):

@jeffknupp sorry this might be a stupid question but - how can I grab this change? pip upgrade didn't seem to catch it

<!-- gh-comment-id:236463352 --> @Datamance commented on GitHub (Jul 31, 2016): @jeffknupp sorry this might be a stupid question but - how can I grab this change? pip upgrade didn't seem to catch it
Author
Owner

@Datamance commented on GitHub (Aug 2, 2016):

@jeffknupp ? Friendly ping. Again, sorry if it's an ignorant question, I'm not super familiar with package distribution.

<!-- gh-comment-id:237052659 --> @Datamance commented on GitHub (Aug 2, 2016): @jeffknupp ? Friendly ping. Again, sorry if it's an ignorant question, I'm not super familiar with package distribution.
Author
Owner

@Datamance commented on GitHub (Aug 3, 2016):

Changed it manually in my site packages so I could try other stuff. Still getting 500's, but for other reasons.

How often do you upload to python package index?

<!-- gh-comment-id:237140028 --> @Datamance commented on GitHub (Aug 3, 2016): Changed it manually in my site packages so I could try other stuff. Still getting 500's, but for other reasons. How often do you upload to python package index?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sandman2-jeffknupp#22
No description provided.