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

TypeError: Argument #1 ($handle) Must Be String in Statamic Forms Import Command #389

Closed
emran-alhaddad opened this issue Dec 9, 2024 · 8 comments · Fixed by #390
Closed
Labels
bug Something isn't working

Comments

@emran-alhaddad
Copy link

emran-alhaddad commented Dec 9, 2024

Bug description

What happened?
Running the command php please eloquent:import-forms and selecting to import form submissions results in a TypeError. The error message indicates that Statamic\Fields\Blueprint::setHandle() expects a string, but null was given.

What did you expect to happen?
The forms and their submissions should be imported successfully without errors.

Error Output:

TypeError 

Statamic\Fields\Blueprint::setHandle(): Argument #1 ($handle) must be of type string, null given, called in vendor/statamic/cms/src/Forms/Form.php on line 80

at vendor/statamic/cms/src/Fields/Blueprint.php:50
     46▕     private $lastBlueprintHandle = null;
     47▕ 
     48▕     private ?Columns $columns = null;
     49▕ 
  ➜  50▕     public function setHandle(string $handle)
     51▕     {
     52▕         $this->handle = $handle;
     53▕ 
     54▕         return $this;

      +15 vendor frames 

  16  [internal]:0
      Statamic\Stache\Stores\Store::Statamic\Stache\Stores\{closure}()
      +4 vendor frames 

  21  [internal]:0
      Statamic\Stache\Query\SubmissionQueryBuilder::Statamic\Stache\Query\{closure}()

How to reproduce

  1. Navigate to the project directory.

  2. Run the following command: php please eloquent:import-forms

When prompted:

Do you want to import forms? (yes/no) [no]:
> yes

Do you want to import form submissions? (yes/no) [no]:
> yes
  1. Observe the TypeError regarding Blueprint::setHandle().

Logs

No response

Environment

Environment
Application Name: ****
Laravel Version: 11.34.2
PHP Version: 8.2.22
Composer Version: 2.5.5
Environment: production
Debug Mode: ENABLED
URL: ***
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Sites: 2 (Arabic, English)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.42.0 PRO

Statamic Addons
isaadsalman/headless-refresh: 1.0.0
ndx/statamic-bard-color-picker: 2.0.0
statamic/eloquent-driver: 4.19.0

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: file
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent

Additional details

this is one of the samples of forms submissions that give the issue
form blueprint:

tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: subject
            field:
              type: text
              display: Subject
              validate:
                - required
          -
            handle: first_name
            field:
              type: text
              display: 'First Name'
              width: 50
          -
            handle: last_name
            field:
              type: text
              display: 'Last Name'
              width: 50
          -
            handle: gender
            field:
              options:
                male: 'Male / ذكر'
                female: 'Female / انثى'
              type: select
              display: Gender
          -
            handle: email
            field:
              input_type: email
              type: text
              display: Email
          -
            handle: company_name
            field:
              type: text
              display: 'Company Name'
          -
            handle: job_title
            field:
              type: text
              display: 'Job Title'
          -
            handle: phone
            field:
              type: text
              display: Phone

form submission:

subject: Test
first_name: test
last_name: test
gender: Male
email: [email protected]
company_name: 'test'
job_title: 'test'
phone: '0555555555'
@emran-alhaddad emran-alhaddad added the bug Something isn't working label Dec 9, 2024
@ryanmitchell
Copy link
Contributor

Can you please provide the full stack trace, again inside backticks (``).

@emran-alhaddad
Copy link
Author

@ryanmitchell
Thank you for your response. Unfortunately, I’m unable to share the full stack trace due to security and privacy concerns. However, I can provide additional details or specific error messages if that would be helpful. Let me know how you'd like to proceed.

@ryanmitchell
Copy link
Contributor

At the moment we don't have enough to work with, as you've not shared the full error trace. If you could please provide it with anything confidential redacted then we can look into it further.

@emran-alhaddad
Copy link
Author

@ryanmitchell
I understand the need for more details. However, due to security policies, I am unable to share the full stack trace. I can provide a redacted version with any sensitive information removed. Would that work for you?

@ryanmitchell
Copy link
Contributor

Feel free to share it confidentially with [email protected].

Alternatively you can make a sample repository showing the issue without your protected data.

@emran-alhaddad
Copy link
Author

This is a complete log for same project locally from log file I removed sensitive info. please tell me if this is enough or still need anything else

[2024-12-09 14:13:58] locale.ERROR: Statamic\Fields\Blueprint::setHandle(): Argument #1 ($handle) must be of type string, null given, called in EmranPc/vendor/statamic/cms/src/Forms/Form.php on line 80 {"exception":"[object] (TypeError(code: 0): Statamic\\Fields\\Blueprint::setHandle(): Argument #1 ($handle) must be of type string, null given, called in EmranPc/vendor/statamic/cms/src/Forms/Form.php on line 80 at EmranPc/vendor/statamic/cms/src/Fields/Blueprint.php:50)
[stacktrace]
#0 EmranPc/vendor/statamic/cms/src/Forms/Form.php(80): Statamic\\Fields\\Blueprint->setHandle(NULL)
#1 EmranPc/vendor/statamic/cms/src/Data/AbstractAugmented.php(166): Statamic\\Forms\\Form->blueprint()
#2 EmranPc/vendor/statamic/cms/src/Data/AbstractAugmented.php(160): Statamic\\Data\\AbstractAugmented->blueprintFields()
#3 EmranPc/vendor/statamic/cms/src/Data/AbstractAugmented.php(123): Statamic\\Data\\AbstractAugmented->fieldtype('fromModel')
#4 EmranPc/vendor/statamic/cms/src/Data/AbstractAugmented.php(75): Statamic\\Data\\AbstractAugmented->wrapDeferredValue('fromModel')
#5 EmranPc/vendor/statamic/cms/src/Data/HasAugmentedInstance.php(17): Statamic\\Data\\AbstractAugmented->get('fromModel')
#6 EmranPc/vendor/statamic/cms/src/Data/HasAugmentedInstance.php(125): Statamic\\Forms\\Form->augmentedValue('fromModel')
#7 EmranPc/vendor/statamic/eloquent-driver/src/Forms/FormRepository.php(20): Statamic\\Forms\\Form->__call('fromModel', Array)
#8 EmranPc/vendor/spatie/blink/src/Blink.php(306): Statamic\\Eloquent\\Forms\\FormRepository->Statamic\\Eloquent\\Forms\\{closure}()
#9 EmranPc/vendor/statamic/cms/src/Support/Blink.php(18): Spatie\\Blink\\Blink->once('eloquent-forms-...', Object(Closure))
#10 EmranPc/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(357): Statamic\\Support\\Blink->__call('once', Array)
#11 EmranPc/vendor/statamic/eloquent-driver/src/Forms/FormRepository.php(13): Illuminate\\Support\\Facades\\Facade::__callStatic('once', Array)
#12 EmranPc/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(357): Statamic\\Eloquent\\Forms\\FormRepository->find('contact_us')
#13 EmranPc/vendor/statamic/cms/src/Stache/Stores/FormSubmissionsStore.php(50): Illuminate\\Support\\Facades\\Facade::__callStatic('find', Array)
#14 EmranPc/vendor/statamic/cms/src/Stache/Stores/Store.php(302): Statamic\\Stache\\Stores\\FormSubmissionsStore->makeItemFromFile('EmranPc...', 'subject: test\\nf...')
#15 [internal function]: Statamic\\Stache\\Stores\\Store->Statamic\\Stache\\Stores\\{closure}(1733663089, 'EmranPc...')
#16 EmranPc/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(605): array_map(Object(Closure), Array, Array)
#17 EmranPc/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(785): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#18 EmranPc/vendor/statamic/cms/src/Stache/Stores/Store.php(300): Illuminate\\Support\\Collection->map(Object(Closure))
#19 EmranPc/vendor/statamic/cms/src/Stache/Query/SubmissionQueryBuilder.php(66): Statamic\\Stache\\Stores\\Store->paths()
#20 [internal function]: Statamic\\Stache\\Query\\SubmissionQueryBuilder->Statamic\\Stache\\Query\\{closure}('contact_us', 0)
#21 EmranPc/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(605): array_map(Object(Closure), Array, Array)
#22 EmranPc/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(785): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#23 EmranPc/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(425): Illuminate\\Support\\Collection->map(Object(Closure))
#24 EmranPc/vendor/statamic/cms/src/Stache/Query/SubmissionQueryBuilder.php(65): Illuminate\\Support\\Collection->flatMap(Object(Closure))
#25 EmranPc/vendor/statamic/cms/src/Stache/Query/SubmissionQueryBuilder.php(59): Statamic\\Stache\\Query\\SubmissionQueryBuilder->getKeysFromForms(Array)
#26 EmranPc/vendor/statamic/cms/src/Stache/Query/Builder.php(27): Statamic\\Stache\\Query\\SubmissionQueryBuilder->getFilteredKeys()
#27 EmranPc/vendor/statamic/cms/src/Stache/Query/Builder.php(46): Statamic\\Stache\\Query\\Builder->resolveKeys()
#28 EmranPc/vendor/statamic/cms/src/Query/Concerns/FakesQueries.php(18): Statamic\\Stache\\Query\\Builder->Statamic\\Stache\\Query\\{closure}()
#29 EmranPc/vendor/statamic/cms/src/Stache/Query/Builder.php(45): Statamic\\Query\\Builder->withFakeQueryLogging(Object(Closure))
#30 EmranPc/vendor/statamic/cms/src/Query/Builder.php(584): Statamic\\Stache\\Query\\Builder->Statamic\\Stache\\Query\\{closure}()
#31 EmranPc/vendor/statamic/cms/src/Stache/Query/Builder.php(45): Statamic\\Query\\Builder->onceWithColumns(Array, Object(Closure))
#32 EmranPc/vendor/statamic/cms/src/Stache/Repositories/SubmissionRepository.php(29): Statamic\\Stache\\Query\\Builder->get()
#33 EmranPc/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(357): Statamic\\Stache\\Repositories\\SubmissionRepository->whereForm('contact_us')
#34 EmranPc/vendor/statamic/cms/src/Forms/Form.php(323): Illuminate\\Support\\Facades\\Facade::__callStatic('whereForm', Array)
#35 EmranPc/vendor/statamic/eloquent-driver/src/Commands/ImportForms.php(72): Statamic\\Forms\\Form->submissions()
#36 EmranPc/vendor/laravel/framework/src/Illuminate/Console/Concerns/InteractsWithIO.php(267): Statamic\\Eloquent\\Commands\\ImportForms->Statamic\\Eloquent\\Commands\\{closure}(Object(Statamic\\Forms\\Form), Object(Symfony\\Component\\Console\\Helper\\ProgressBar))
#37 EmranPc/vendor/statamic/eloquent-driver/src/Commands/ImportForms.php(62): Illuminate\\Console\\Command->withProgressBar(Object(Illuminate\\Support\\Collection), Object(Closure))
#38 EmranPc/vendor/statamic/eloquent-driver/src/Commands/ImportForms.php(45): Statamic\\Eloquent\\Commands\\ImportForms->importForms()
#39 EmranPc/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Statamic\\Eloquent\\Commands\\ImportForms->handle()
#40 EmranPc/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#41 EmranPc/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#42 EmranPc/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#43 EmranPc/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#44 EmranPc/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\\Container\\Container->call(Array)
#45 EmranPc/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#46 EmranPc/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#47 EmranPc/vendor/symfony/console/Application.php(1047): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#48 EmranPc/vendor/symfony/console/Application.php(316): Symfony\\Component\\Console\\Application->doRunCommand(Object(Statamic\\Eloquent\\Commands\\ImportForms), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#49 EmranPc/vendor/symfony/console/Application.php(167): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#50 EmranPc/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#51 EmranPc/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1203): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#52 EmranPc/please(18): Illuminate\\Foundation\\Application->handleCommand(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
#53 {main}
"} 

@duncanmcclean
Copy link
Member

Thanks!

@ryanmitchell
Copy link
Contributor

I've opened a PR to address this issue - are you able to give it a go and see if it works for you?

#390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants