Shopify / Shopify/shopify-app-template-php

BUG: Session schema truncates long list of scopes.

Open
#514 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
340
Forks
108
PR merge metrics
No merged PRs in 30d

Description

Issue summary

Getting this error:

Failed to save session to database: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(255)

The list of scopes being saved is:

read_locations,read_price_rules,read_product_listings,write_assigned_fulfillment_orders,write_customers,write_draft_orders,write_fulfillments,write_inventory,write_merchant_managed_fulfillment_orders,write_order_edits,write_orders,write_products,write_returns,write_third_party_fulfillment_orders

...which is 296 characters.

Adding this migration to fix, appears to work:

        Schema::table('sessions', function (Blueprint $table) {
            $table->text('scope')->nullable()->change();  // Don't impose a length limit
        });

Expected behavior

Session should save the scope list however long it is.

Actual behavior

Failed to save session to database: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(255)

Steps to reproduce the problem

  1. Put a long list of scopes (> 255 chars) in your TOML and deploy
  2. Attempt to use the app
  3. Get 500 error, SQL truncation error in log

NOTE: This issue probably applies to other app templates as well. They should be reviewed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the sessions table schema and the migration entry point that defines the scope column, then review how the TOML scope list is persisted. Reproduce with a scope list over 255 characters and verify that the schema accepts it without the PostgreSQL truncation error; review the other app templates as noted.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, postgresql
Domain
backend, database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.