Skip to content

fix: update code generation base template to match updated input from rails

Tian Gao requested to merge 490582-fix_template_input_variables into main

What does this merge request do and why?

This commit updated the params in rails

but template in AIGW is expecting old input variables.

This is causing error:

c2024-10-20 21:15:02 [error ] "Input to ChatPromptTemplate is missing variables {'trimmed_suffix', 'trimmed_prefix'}. Expected: ['examples_array', 'file_name', 'language', 'libraries', 'related_files', 'related_snippets', 'trimmed_prefix', 'trimmed_suffix', 'user_instruction'] Received: ['prefix', 'instruction', 'language', 'file_name', 'examples_array', 'trimmed_content_above_cursor', 'trimmed_content_below_cursor', 'related_files', 'related_snippets', 'libraries', 'user_instruction']\nNote: if you intended {trimmed_suffix} to be part of the string and not a variable, please escape it with double curly braces like: '{{trimmed_suffix}}'." backtrace=Traceback (most recent call last):

https://gitlab.slack.com/archives/C8PKBH3M5/p1729267287058669

https://gitlab.slack.com/archives/C048Z2DHWGP/p1729280294637399

To verify:

[8] pry(main)> ::Feature.enable(:anthropic_code_gen_aigw_migration)
  TRANSACTION (0.4ms)  BEGIN /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  Feature::FlipperFeature Load (0.6ms)  SELECT "features".* FROM "features" WHERE "features"."key" = 'anthropic_code_gen_aigw_migration' ORDER BY "features"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  TRANSACTION (0.1ms)  COMMIT /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:412:in `commit'*/
  TRANSACTION (0.1ms)  BEGIN /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  Feature::FlipperGate Load (0.4ms)  SELECT "feature_gates".* FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'anthropic_code_gen_aigw_migration' /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  Feature::FlipperGate Load (0.1ms)  SELECT "feature_gates".* FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'anthropic_code_gen_aigw_migration' AND "feature_gates"."key" = 'boolean' /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  Feature::FlipperGate Create (2.4ms)  INSERT INTO "feature_gates" ("feature_key", "key", "value", "created_at", "updated_at") VALUES ('anthropic_code_gen_aigw_migration', 'boolean', 'true', '2024-10-03 17:30:08.216348', '2024-10-03 17:30:08.216348') RETURNING "id" /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:378:in `block in transaction'*/
  TRANSACTION (0.1ms)  COMMIT /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/lib/gitlab/database.rb:412:in `commit'*/
  Feature::FlipperGate Pluck (0.1ms)  SELECT "feature_gates"."key", "feature_gates"."value" FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'anthropic_code_gen_aigw_migration' /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:/ee/lib/ee/feature.rb:37:in `enable'*/
WARNING: Understand the stability and security risks of enabling in-development features with feature flags.
See https://docs.gitlab.com/ee/administration/feature_flags.html#risks-when-enabling-features-still-in-development for more information.
=> true
[9] pry(main)> ::Feature.enabled?(:anthropic_code_gen_aigw_migration, User.first)
  User Load (1.1ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 /*application:console,db_config_name:main,console_hostname:Tians-MBP-2,console_username:tiangao,line:(pry):9:in `__pry__'*/
=> true
  • On master when triggering code generation it fails
  • On this branch when triggering code generation if works:

Screenshot_2024-10-20_at_9.53.41_PM

Edited by Tian Gao

Merge request reports

Loading