- Issue created by @psf_
- 🇮🇳India vishal.kadam Mumbai
Thank you for applying!
Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smoother review.
The important notes are the following.
- If you have not done it yet, you should run
phpcs --standard=Drupal,DrupalPractice
on the project, which alone fixes most of what reviewers would report. - For the time this application is open, only your commits are allowed.
- The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
- We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.
To the reviewers
Please read How to review security advisory coverage applications → , Application workflow → , What to cover in an application review → , and Tools to use for reviews → .
The important notes are the following.
- It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
- Reviewers should show the output of a CLI tool → only once per application.
- It may be best to have the applicant fix things before further review.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues → .
- If you have not done it yet, you should run
- 🇮🇳India vishal.kadam Mumbai
1. Fix phpcs issues.
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml openai_client/ FILE: openai_client/query.txt -------------------------------------------------------------------------------- FOUND 16 ERRORS AND 1 WARNING AFFECTING 16 LINES -------------------------------------------------------------------------------- 1 | WARNING | Line exceeds 80 characters; contains 133 characters 59 | ERROR | Missing short description in doc comment 64 | ERROR | Missing short description in doc comment 69 | ERROR | Parameter $api is not described in comment 69 | ERROR | Parameter $dateFormatter is not described in comment 154 | ERROR | The array declaration extends to column 93 (the limit is 80). The array content should be split up over multiple lines 155 | ERROR | The array declaration extends to column 100 (the limit is 80). The array content should be split up over multiple lines 156 | ERROR | The array declaration extends to column 108 (the limit is 80). The array content should be split up over multiple lines 158 | ERROR | The array declaration extends to column 137 (the limit is 80). The array content should be split up over multiple lines 159 | ERROR | The array declaration extends to column 112 (the limit is 80). The array content should be split up over multiple lines 160 | ERROR | The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines 270 | ERROR | Description for the @return value is missing 282 | ERROR | Description for the @return value is missing 292 | ERROR | Description for the @return value is missing 298 | ERROR | Doc comment is empty 315 | ERROR | Description for the @return value is missing 325 | ERROR | Description for the @return value is missing -------------------------------------------------------------------------------- FILE: openai_client/src/OpenAIClientWrapper.php ------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE ------------------------------------------------------------------------------- 68 | ERROR | [x] Whitespace found at end of line ------------------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------
2. FILE: openai_client.info.yml
package: Custom
This line is used by custom modules created for specific sites. It is not a package name used for projects hosted on drupal.org.
3. FILE: openai_client.module
/** * @file * Primary module hooks for OpenAI Client module. */
Drupal does not have primary and secondary hooks. Instead of that, it is preferable to use the usual description: “Hook implementations for the [module name] module”, where [module name] is the name of the module given in its .info.yml file.
4. FILE: src/Controller/AssistantsListController.php
// { // "id": "asst_wMdO2WcFgvAQgQhez5fZ4wxd", // "object": "assistant", // "createdAt": 1699353422, // "name": "Prueba", // "description": null, // "model": "gpt-4-1106-preview", // "instructions": null, // "tools": [], // "fileIds": [], // "metadata": [] // }
FILE: src/Form/AssistantEditForm.php
// $session->set($this->getFormId(), $form_state->getValue('value'));
Remove commented code.
5. FILE: src/Controller/AssistantsListController.php
/** * The entity type manager. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager;
The parent class already has properties and methods for the entity type manager object. There is no need to redefine properties for the same purpose; instead, the parent class methods should be used.
6. FILE: src/Controller/AssistantsListController.php
/** * The controller constructor. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. * @param \Drupal\openai_client\OpenAIClientWrapper $api * Open API wrapper. * @param \Drupal\Core\Datetime\DateFormatter $dateFormatter * Date formatter. * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack * The request stack. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, OpenAIClientWrapper $api, DateFormatter $dateFormatter, RequestStack $requestStack) {
FILE: src/Form/AssistantEditForm.php
/** * Constructor. * * @param \Drupal\openai_client\OpenAIClientWrapper $api * Open API wrapper. */ public function __construct(OpenAIClientWrapper $api) {
FILE: src/Form/CreateImageForm.php
/** * Constructor. * * @param \Drupal\openai_client\OpenAIClientWrapper $api * OpenAI client API. */ public function __construct(OpenAIClientWrapper $api) {
FILE: src/Form/SettingsForm.php
/** * Constructs a \Drupal\system\ConfigFormBase object. * * @param \Drupal\openai_client\OpenAIClientWrapper $api * Open API wrapper. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. * @param \Drupal\Core\Datetime\DateFormatter $dateFormatter * Date formatter. */ public function __construct(OpenAIClientWrapper $api, ConfigFactoryInterface $config_factory, DateFormatter $dateFormatter) {
The documentation comment for constructors is not mandatory anymore, If it is given, the description must be “Constructs a new [class name] object”, where [class name] includes the class namespace.
7. FILE: src/Form/SettingsForm.php
parent::__construct($config_factory);
ConfigFormBase::__construct() requires two parameters. See the change record → .
FILE: openai_client.info.yml
Given the changes in ConfigFormBase, the module cannot be compatible with Drupal releases before 10.2.0.
- 🇪🇸Spain psf_ Huelva
Thank you so much! 😊
I will fix the issues as soon as possible.
Do you have any suggestions for the .gitlab-ci.yml configuration? I have set it up, but it doesn’t detect the failures.
Here is the pipeline: https://git.drupalcode.org/project/openai_client/-/pipelines/428605 - 🇮🇳India vishal.kadam Mumbai
I have reviewed the `.gitlab-ci.yml` configuration, and everything looks good.
As for the pipeline, I can see that it has passed.
- 🇪🇸Spain psf_ Huelva
Hi, I fixed all, I think :_ D
[X] 1. Fix phpcs issues.
- I ignored query.txt because it contains chat dump data.
- Fix openai_client/src/OpenAIClientWrapper.php
[X] 2. FILE: openai_client.info.yml
- I Changed package to "AI", how in the module ai/ of the "AI Initiative".
[X] 3. FILE: openai_client.module
[X] 4. FILE: src/Controller/AssistantsListController.php
[X] FILE: src/Form/AssistantEditForm.php
[X] 5. FILE: src/Controller/AssistantsListController.php
[X] 6. FILE: src/Controller/AssistantsListController.php
[X] FILE: src/Form/AssistantEditForm.php
[X] FILE: src/Form/CreateImageForm.php
[X] FILE: src/Form/SettingsForm.php
[X] 7. FILE: src/Form/SettingsForm.php
[X] FILE: openai_client.info.ymlThanks for review `.gitlab-ci.yml` : )
- 🇮🇳India vishal.kadam Mumbai
Rest looks fine to me.
Let’s wait for a Code Review Administrator to take a look and if everything goes fine, you will get the role.
- 🇪🇸Spain psf_ Huelva
Hi,
Must be the status changed to "Reviewed & tested by the community"?
From What to expect from the review process → :
Once all issues have been addressed:
The reviewers will change the status of the issue to Reviewed & tested by the community
After that, a project moderator will validate the review, granting the applicants the role to be able to opt projects into security advisory coverage, and changing the status of the application to Fixed. If new issues are identified, the status could be set back to Needs work. - 🇮🇹Italy apaderno Brescia, 🇮🇹
- The following points are just a start and don't necessarily encompass all of the changes that may be necessary
- A specific point may just be an example and may apply in other places
- A review is about code that does not follow the coding standards, contains possible security issue, or does not correctly use the Drupal API
- The single review points are not ordered, not even by importance
src/Controller/AssistantsListController.php
catch (\Exception $e) { $this->messenger()->addError($e->getMessage()); return [ '#type' => 'item', '#markup' => $this->t('Connection error'), ]; }
The first argument passed to
addError()
and similar messenger methods must be a translatable string./** * The request stack. * * @var \Symfony\Component\HttpFoundation\RequestStack */ protected $requestStack;
There is no need to use that property, since the
Request
object is automatically passed to the page controller, if it is defined as follows. See Using parameters in routes → .public function content(AccountInterface $user, Request $request) { // … }
src/Form/CreateImageForm.php
$form_state->setRebuildInfo(['images' => $imageUrls]); $this->messenger()->addStatus($this->t('The image/s was generated.'));
If the message changes between singular and plural, there is
formatPlural()
.'#title' => self::t('OpenAI API documentation'), '#url' => Url::fromUri('https://platform.openai.com/docs/introduction/overview'), '#attributes' => [ 'target' => '_blank', 'rel' => 'noopener noreferrer', ],
StringTranslationTrait::t()
is not a static method.catch (\Exception $e) { $form_state->setErrorByName('api-token', $e->getMessage()); }
The second parameter for
setErrorByName()
must be a translatable string.