vuestorefront / shopware-pwa

Shopware PWA for eCommerce. Headless storefront solution for Shopware 6, which communicates through the SalesChannel-API. Always Open Source, MIT license. Made with :blue_heart: by shopware AG & Vue Storefront.
https://frontends.shopware.com
MIT License
345 stars 103 forks source link

[BUG] 500 #565

Closed ivosanchez closed 4 years ago

ivosanchez commented 4 years ago

hi, I have been trying all sort of combinations, and all I can get is a 500. I was wondering if you could check the log, and give me a clue as to what might be the issue . thanks a lot, :-)

ERROR { status: 500, statusText: 'Internal Server Error', headers: { date: 'Sun, 29 Mar 2020 19:57:24 GMT', server: 'Apache', 'x-powered-by': 'PHP/7.3.15', 'cache-control': 'max-age=0, must-revalidate, private', 'sw-version-id': ', ', 'sw-language-id': '2fbb5fe2e29a4d70aa5854ce7ce3e20b, 2fbb5fe2e29a4d70aa5854ce7ce3e20b', 'sw-context-token': 'mw1CVvI04grYOAjlWqq16rdt3H3IUqzn, mw1CVvI04grYOAjlWqq16rdt3H3IUqzn', 'x-frame-options': 'deny, deny', 'x-debug-token': 'c773f5', 'x-debug-token-link': 'http://192.168.64.13/_profiler/c773f5', 'x-robots-tag': 'noindex', 'access-control-allow-origin': '', 'access-control-allow-methods': 'GET,POST,PUT,PATCH,DELETE', 'access-control-allow-headers': 'Content-Type,Authorization,sw-context-token,sw-access-key,sw-language-id,sw-version-id', 'x-previous-debug-token': 'bd7a04', expires: 'Sun, 29 Mar 2020 19:57:24 GMT', 'set-cookie': [ 'session-=28o2qemohja4bdc75skf8br69r; path=/; HttpOnly' ], vary: 'Cookie', connection: 'close', 'transfer-encoding': 'chunked', 'content-type': 'application/json' }, config: { url: 'http://192.168.64.13//api/oauth/token', method: 'post', data: '{"client_id":"administration","grant_type":"password","scopes":"write","username":"testuser","password":"p@ssword1"}', headers: { Accept: 'application/json, text/plain, /*', 'Content-Type': 'application/json;charset=utf-8', 'User-Agent': 'axios/0.19.2', 'Content-Length': 116 }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, adapter: [Function: httpAdapter], xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus] }, request: ClientRequest { _events: [Object: null prototype] { socket: [Function], abort: [Function], aborted: [Function], error: [Function], timeout: [Function], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 6, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: Socket { connecting: false, _hadError: false, _handle: [TCP], _parent: null, _host: null, _readableState: [ReadableState], readable: true, _events: [Object], _eventsCount: 7, _maxListeners: undefined, _writableState: [WritableState], writable: false, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, parser: null, _httpMessage: [Circular],

    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0 },
 connection:
  Socket {
    connecting: false,
    _hadError: false,
    _handle: [TCP],
    _parent: null,
    _host: null,
    _readableState: [ReadableState],
    readable: true,
    _events: [Object],
    _eventsCount: 7,
    _maxListeners: undefined,
    _writableState: [WritableState],
    writable: false,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null,
    parser: null,
    _httpMessage: [Circular],
    [Symbol(asyncId)]: 23943,
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0 },
 _header:
  'POST //api/oauth/token HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json;charset=utf-8\r\nUser-Agent: axios/0.19.2\r\nContent-Length: 116\r\nHost: 192.168.64.13\r\nConnection: close\r\n\r\n',
 _onPendingData: [Function: noopPendingOutput],
 agent:
  Agent {
    _events: [Object],
    _eventsCount: 1,
    _maxListeners: undefined,
    defaultPort: 80,
    protocol: 'http:',
    options: [Object],
    requests: {},
    sockets: [Object],
    freeSockets: {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256 },
 socketPath: undefined,
 timeout: undefined,
 method: 'POST',
 path: '//api/oauth/token',
 _ended: true,
 res:
  IncomingMessage {
    _readableState: [ReadableState],
    readable: false,
    _events: [Object],
    _eventsCount: 3,
    _maxListeners: undefined,
    socket: [Socket],
    connection: [Socket],
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: true,
    headers: [Object],
    rawHeaders: [Array],
    trailers: {},
    rawTrailers: [],
    aborted: false,
    upgrade: false,
    url: '',
    method: null,
    statusCode: 500,
    statusMessage: 'Internal Server Error',
    client: [Socket],
    _consuming: true,
    _dumped: false,
    req: [Circular],
    responseUrl: 'http://192.168.64.13//api/oauth/token',
    redirects: [] },
 aborted: undefined,
 timeoutCb: null,
 upgradeOrConnect: false,
 parser: null,
 maxHeadersCount: null,
 _redirectable:
  Writable {
    _writableState: [WritableState],
    writable: true,
    _events: [Object],
    _eventsCount: 2,
    _maxListeners: undefined,
    _options: [Object],
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 116,
    _requestBodyBuffers: [],
    _onNativeResponse: [Function],
    _currentRequest: [Circular],
    _currentUrl: 'http://192.168.64.13//api/oauth/token' },
 [Symbol(isCorked)]: false,
 [Symbol(outHeadersKey)]:
  [Object: null prototype] {
    accept: [Array],
    'content-type': [Array],
    'user-agent': [Array],
    'content-length': [Array],
    host: [Array] } },

data: { type: 'https://tools.ietf.org/html/rfc2616#section-10', title: 'An error occurred', status: 500, detail: 'Call to a member function getSource() on null', class: 'Error', trace: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object] ] } } ✔ Updating dependencies Generated Shopware PWA project! Type 'shopware-pwa dev' and start exploring

mkucmus commented 4 years ago

hi @ivosanchez, thanks for reporting the issue. The API response says that there is an internal server error, so It looks like your Shopware instance wasn't installed/configured properly.

The response from your local sw instance is:

title: 'An error occurred', status: 500, detail: 'Call to a member function getSource() on null', class: 'Error', trace: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object] ] } }

maybe there is something worth looking at.

you may also try to debug the request as same as shopware-cli does under the hood, I mean:

curl -X POST \ http://192.168.64.13/api/oauth/token \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache,no-cache' \ -d '{ "client_id": "administration", "grant_type": "password", "scopes": "write", "username": "testuser", "password": "p@ssword1" }'

If it fails, it means that the shopware instance is not able to get the oath token correctly, and there is no way to fetch the corresponding plugins.

Rigo-m commented 4 years ago

Make sure to install this version of shopware: https://github.com/shopware/platform Make sure to install the master branch of the plugin (https://github.com/elkmod/SwagShopwarePwa)

Make sure that the plugin is installed and activated.

Logging into the shopware dashboard should tell you that you are using version v9999999 Developer Version, the SwagShopwarePwa plugin should have the same version. After installing the plugin remember to clear the cache (bin/console cache:clear) and refresh SEO URLs (bin/console dal:refresh:index).

Re-run shopware-pwa init and it should work (when asked to do so, don't put shopware admin credentials, there's still a bug in that regard). This should fix the issue, it worked for me.

patzick commented 4 years ago

hey @ivosanchez please reopen with an update if it's still an issue

Rigo-m commented 4 years ago

For whomever will come later: The bug with the shopware admin cretentials has been fixed.

Rember to match SwagShopwarePwa version with Shopware version to avoid any conflict that may lead to a 500 error.