Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Extended metadata type attributes needed to accept both controlled vocabulary suggestions and free text via an allow_free_text flag in the EMT JSON schema.

  • Schema: Added allow_free_text to EMT attribute schema (both basic and CV/linked variants) so JSON uploads can declare free-text allowance.
  • Import: Persisted allow_free_text into allow_cv_free_text when creating extended metadata attributes from JSON.
  • Serialization: Exposed allow_free_text in the extended metadata type serializer for API consumers.
  • Tests/fixtures: Updated CV EMT fixture and extractor test to cover allow_free_text behavior.

Example:

{
  "attributes": [
    {
      "title": "Topics",
      "type": "Controlled Vocabulary",
      "ID": "CV_TOPICS_ID",
      "allow_free_text": true
    }
  ]
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https -I . -I ./libsass/include --gdwarf-5 --64 -o utf8_string.o /tmp/ccrlT5ol.s -I -g++ comp�� ITS=64 RCE cal/share/gem/ru-I or/bundle/ruby/3echo -I GES as (dns block)
  • oss-binaries.phusionpassenger.com
    • Triggering command: /usr/bin/curl curl -f -L -o rubyext-ruby-3.2.3-x86_64-linux.tar.gz.tmp -s -S --connect-timeout 4 --speed-time 5 --speed-limit 1 --max-time 10 REDACTED lient or/bundle/ruby/3-I p or/bundle/ruby/3-I (dns block)
  • s3.amazonaws.com
    • Triggering command: /usr/bin/curl curl -f -L -o rubyext-ruby-3.2.3-x86_64-linux.tar.gz.tmp -s -S --connect-timeout 4 --speed-time 5 --speed-limit 1 --max-time 10 REDACTED lient bgit2/deps/pcre p bgit2/deps/xdiff (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

#2449
could you work on this github issue


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix JSON schema validation errors in API Support allow_free_text in extended metadata controlled vocab attributes Dec 10, 2025
Copilot AI requested a review from whomingbird December 10, 2025 11:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for an allow_free_text flag in extended metadata controlled vocabulary attributes, enabling controlled vocabulary fields to optionally accept free-text values in addition to predefined terms.

  • Added allow_free_text to the EMT JSON schema for both basic and CV/linked attribute definitions
  • Persisted the flag from JSON imports to the allow_cv_free_text database column
  • Exposed allow_free_text in the API serializer for consumer applications
  • Updated tests and fixtures to validate the new functionality

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/seek/extended_metadata_type/extended_metadata_type_schema.json Added allow_free_text boolean property to both oneOf schema variants for attribute definitions
lib/seek/extended_metadata_type/extended_metadata_type_extractor.rb Modified to extract and persist allow_free_text from JSON to allow_cv_free_text attribute
app/serializers/extended_metadata_type_serializer.rb Added allow_free_text field to API response serialization
public/api/definitions/_schemas.yml Added allow_free_text boolean property to API schema definition
test/fixtures/files/extended_metadata_type/valid_emt_with_cv_with_ontologies.json Added "allow_free_text": true to test fixture
test/unit/extended_metadatas/emt_extractor_test.rb Added assertion to verify allow_cv_free_text is correctly extracted
test/factories/extended_metadata_types.rb Set allow_cv_free_text: true for CV list and false for CV attribute to support test scenarios
test/functional/studies_controller_test.rb Added test case for free text validation behavior; numerous formatting improvements (spacing around hash colons)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 34 to 36
"allow_free_text": {
"type": "boolean"
},
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allow_free_text property is defined in the basic attribute schema variant (first oneOf branch) which doesn't restrict the type to controlled vocabulary types. This means allow_free_text could be set for non-CV attribute types like "String", "Integer", "Date", etc., where it has no meaning. Consider either: (1) only including allow_free_text in the second oneOf branch (lines 70-72) where controlled vocabulary types are explicitly enumerated, or (2) adding validation logic to ignore or reject allow_free_text when the type is not a controlled vocabulary type.

Suggested change
"allow_free_text": {
"type": "boolean"
},

Copilot uses AI. Check for mistakes.
Comment on lines 70 to 72
"allow_free_text": {
"type": "boolean"
},
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allow_free_text property is defined for all types in this schema variant, including "Linked Extended Metadata" and "Linked Extended Metadata (multiple)" types where free text doesn't apply (these link to other metadata structures, not controlled vocabularies). While this may be intentionally permissive, consider whether allow_free_text should only be applicable to "Controlled Vocabulary" and "Controlled Vocabulary List" types in the enum on lines 60-65.

Copilot uses AI. Check for mistakes.
Comment on lines 65 to 66
required: attr['required'].present? ? attr['required'] : false,
allow_cv_free_text: attr['allow_free_text'].present? ? attr['allow_free_text'] : false,
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using .present? to check for a boolean attribute is non-idiomatic. While it works in this case (because false.present? returns false, so it defaults to false), it's clearer to use .key? to check for the attribute's existence. Consider: allow_cv_free_text: attr.key?('allow_free_text') ? attr['allow_free_text'] : false. This makes the intent clearer and handles both true and false values explicitly. Note that line 65 has the same pattern for the required attribute.

Suggested change
required: attr['required'].present? ? attr['required'] : false,
allow_cv_free_text: attr['allow_free_text'].present? ? attr['allow_free_text'] : false,
required: attr.key?('required') ? attr['required'] : false,
allow_cv_free_text: attr.key?('allow_free_text') ? attr['allow_free_text'] : false,

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 28 to 29
raise StandardError, "The schema file is not readable!" unless File.readable?(SCHEMA_PATH)

Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a duplicate of line 27 and should be removed.

Suggested change
raise StandardError, "The schema file is not readable!" unless File.readable?(SCHEMA_PATH)

Copilot uses AI. Check for mistakes.
@whomingbird whomingbird marked this pull request as ready for review December 17, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants